use of com.sun.tck.test.TestedAPI in project jtharness by openjdk.
the class TestCaseContext method handleTestedStatements.
/**
* If <code>@TestedStatement</code> annotations are attached to the method of the failed testcase
* all the available data is printed to the log
* @param tcName name of the testcase
*/
private void handleTestedStatements(String tcName) {
List<TestedStatement> statements = new ArrayList<>();
// first adding all @TestedStatement present at testgroup level and all super classes/interfaces
ReflectionUtils.getClassHierarchy(getTestGroupInstance().getClass()).forEach(c -> statements.addAll(Arrays.asList(c.getAnnotationsByType(TestedStatement.class))));
// then processing @TestedStatements present at testcase level
statements.addAll(Arrays.asList(testCaseMethod.getAnnotationsByType(TestedStatement.class)));
if (!statements.isEmpty()) {
printlnToLog(format("Testcase \"{0}\" is based on the following statements: ", tcName));
for (TestedStatement statement : statements) {
StringJoiner texts = new StringJoiner(", ");
for (String text : statement.value()) {
texts.add("\"" + text + "\"");
}
printlnToLog(" - " + texts.toString());
if (!TestedStatement.DEFAULT_SOURCE.equals(statement.source())) {
printlnToLog(" -- from source: \"" + statement.source() + "\"");
} else {
TestedAPI testedAPI = parentContext.getTestGroupInstance().getClass().getAnnotation(TestedAPI.class);
if (testedAPI != null) {
String[] classes = testedAPI.testedClass();
String[] members = testedAPI.testedMember();
String[] packages = testedAPI.testedPackage();
String source = beautifulizeArrayToString(packages) + // filtering out the case when tested class or member are not specified - by default it's an array of {""}
(Arrays.equals(classes, new String[] { "" }) ? "" : "." + beautifulizeArrayToString(classes)) + (Arrays.equals(members, new String[] { "" }) ? "" : "." + beautifulizeArrayToString(members));
printlnToLog(" -- from source: " + source);
}
}
}
}
}
use of com.sun.tck.test.TestedAPI in project jtharness by openjdk.
the class FailingSimpleTestCases method testedAPI_package_classes_methods.
@Test
public void testedAPI_package_classes_methods() {
@TestedAPI(testedPackage = "s.e.g", testedClass = { "TheClass", "TheClass" }, testedMember = { "method1", "method2" })
@TestGroup
class MyTest {
@TestCase
@TestedStatement("a statement")
public void testCase() {
Assert.fail();
}
}
TestResult s = TU.runTestGroup(new MyTest(), TU.EMPTY_ARGV);
Assert.assertTrue(!s.isOK());
Assert.assertEquals("test cases: 1; all failed", s.getMessage());
}
use of com.sun.tck.test.TestedAPI in project jtharness by openjdk.
the class FailingSimpleTestCases method testedAPI_packages_classes.
@Test
public void testedAPI_packages_classes() {
@TestedAPI(testedPackage = { "x.e.r", "s.e.g", "e.t.r" }, testedClass = { "TheClass", "AnotherClass" })
@TestGroup
class MyTest {
@TestCase
@TestedStatement("a statement")
public void testCase() {
Assert.fail();
}
}
TestResult s = TU.runTestGroup(new MyTest(), TU.EMPTY_ARGV);
Assert.assertTrue(!s.isOK());
Assert.assertEquals("test cases: 1; all failed", s.getMessage());
}
use of com.sun.tck.test.TestedAPI in project jtharness by openjdk.
the class FailingSimpleTestCases method testedAPI_packages_classes_method.
@Test
public void testedAPI_packages_classes_method() {
@TestedAPI(testedPackage = { "x.e.r", "s.e.g", "e.t.r" }, testedClass = { "TheClass", "AnotherClass" }, testedMember = "method")
@TestGroup
class MyTest {
@TestCase
@TestedStatement("a statement")
public void testCase() {
Assert.fail();
}
}
TestResult s = TU.runTestGroup(new MyTest(), TU.EMPTY_ARGV);
Assert.assertTrue(!s.isOK());
Assert.assertEquals("test cases: 1; all failed", s.getMessage());
}
use of com.sun.tck.test.TestedAPI in project jtharness by openjdk.
the class FailingSimpleTestCases method testedAPI_packages_classes_methods.
@Test
public void testedAPI_packages_classes_methods() {
@TestedAPI(testedPackage = { "x.e.r", "s.e.g", "e.t.r" }, testedClass = { "TheClass", "AnotherClass" }, testedMember = { "method1", "method2" })
@TestGroup
class MyTest {
@TestCase
@TestedStatement("a statement")
public void testCase() {
Assert.fail();
}
}
TestResult s = TU.runTestGroup(new MyTest(), TU.EMPTY_ARGV);
Assert.assertTrue(!s.isOK());
Assert.assertEquals("test cases: 1; all failed", s.getMessage());
}
Aggregations