Skip to content

Commit

Permalink
Description and display name examples
Browse files Browse the repository at this point in the history
  • Loading branch information
HardNorth committed Oct 14, 2024
1 parent 3364ba8 commit d713616
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.epam.reportportal.example.junit5.annotated;

import com.epam.reportportal.annotations.Description;
import org.junit.jupiter.api.DynamicTest;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestFactory;

import java.util.stream.Stream;

import static org.junit.jupiter.api.DynamicTest.dynamicTest;

@Description("Description from Description annotation on class level")
public class DescriptionTest {

@Test
@Description("Description from Description annotation on method level overrides Description set at class level")
public void testDescriptionTestMethod() {
System.out.println("Inside testDescriptionTestMethod");
}

@Test
public void testDescriptionTestClass() {
System.out.println("Inside testDescriptionTestClass");
}

@TestFactory
@Description("Description from Description annotation on dynamic test factory")
public Stream<DynamicTest> testForTestFactory() {
return Stream.of(dynamicTest("My dynamic test", () -> System.out.println("Inside dynamic test")));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.epam.reportportal.example.junit5.annotated;

import com.epam.reportportal.annotations.DisplayName;
import org.junit.jupiter.api.DynamicTest;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestFactory;

import java.util.stream.Stream;

import static org.junit.jupiter.api.DynamicTest.dynamicTest;

@DisplayName("Display name from DisplayName annotation on class level")
public class DisplayNameTest {
@Test
@DisplayName("Display name from DisplayName annotation on method level")
public void testDisplayName() {
System.out.println("Inside testDisplayName");
}

@TestFactory
@DisplayName("Display name from DisplayName annotation on dynamic test factory")
public Stream<DynamicTest> testForTestFactory() {
return Stream.of(dynamicTest("My dynamic test", () -> System.out.println("Inside dynamic test")));
}

@Test
@org.junit.jupiter.api.DisplayName("Display name from JUnit's annotation on method level")
@DisplayName("Display name from ReportPortal's annotation overrides JUnit's annotation")
public void testDisplayNameOverride() {
System.out.println("Inside testDisplayNameOverride");
}
}

0 comments on commit d713616

Please sign in to comment.