Search in sources :

Example 1 with Theme

use of org.junit.platform.console.options.Theme in project junit5 by junit-team.

the class ConsoleTestExecutor method createDetailsPrintingListener.

private Optional<TestExecutionListener> createDetailsPrintingListener(PrintWriter out) {
    boolean disableAnsiColors = options.isAnsiColorOutputDisabled();
    Theme theme = options.getTheme();
    switch(options.getDetails()) {
        case SUMMARY:
            // summary listener is always created and registered
            return Optional.empty();
        case FLAT:
            return Optional.of(new FlatPrintingListener(out, disableAnsiColors));
        case TREE:
            return Optional.of(new TreePrintingListener(out, disableAnsiColors, theme));
        case VERBOSE:
            return Optional.of(new VerboseTreePrintingListener(out, disableAnsiColors, 16, theme));
        default:
            return Optional.empty();
    }
}
Also used : Theme(org.junit.platform.console.options.Theme)

Example 2 with Theme

use of org.junit.platform.console.options.Theme in project junit5 by junit-team.

the class ConsoleDetailsTests method scanContainerClassAndCreateDynamicTests.

private List<DynamicNode> scanContainerClassAndCreateDynamicTests(Class<?> containerClass) {
    String containerName = containerClass.getSimpleName().replace("TestCase", "");
    // String containerName = containerClass.getSimpleName();
    List<DynamicNode> nodes = new ArrayList<>();
    Map<Details, List<DynamicTest>> map = new EnumMap<>(Details.class);
    for (Method method : findMethods(containerClass, m -> m.isAnnotationPresent(Test.class))) {
        String methodName = method.getName();
        Class<?>[] types = method.getParameterTypes();
        for (Details details : Details.values()) {
            List<DynamicTest> tests = map.computeIfAbsent(details, key -> new ArrayList<>());
            for (Theme theme : Theme.values()) {
                String caption = containerName + "-" + methodName + "-" + details + "-" + theme;
                String[] args = { // 
                "--include-engine", // 
                "junit-jupiter", // 
                "--details", // 
                details.name(), // 
                "--details-theme", // 
                theme.name(), // 
                "--disable-ansi-colors", // 
                "true", // 
                "--include-classname", // 
                containerClass.getCanonicalName(), // 
                "--select-method", // 
                getFullyQualifiedMethodName(containerClass, methodName, types) };
                String displayName = methodName + "() " + theme.name();
                String dirName = "console/details/" + containerName.toLowerCase();
                String outName = caption + ".out.txt";
                tests.add(DynamicTest.dynamicTest(displayName, new Runner(dirName, outName, args)));
            }
        }
    }
    map.forEach((details, tests) -> nodes.add(DynamicContainer.dynamicContainer(details.name(), tests)));
    return nodes;
}
Also used : ArrayList(java.util.ArrayList) Method(java.lang.reflect.Method) DynamicTest(org.junit.jupiter.api.DynamicTest) Details(org.junit.platform.console.options.Details) Test(org.junit.jupiter.api.Test) DynamicTest(org.junit.jupiter.api.DynamicTest) Theme(org.junit.platform.console.options.Theme) DynamicNode(org.junit.jupiter.api.DynamicNode) ArrayList(java.util.ArrayList) Arrays.asList(java.util.Arrays.asList) List(java.util.List) EnumMap(java.util.EnumMap)

Aggregations

Theme (org.junit.platform.console.options.Theme)2 Method (java.lang.reflect.Method)1 ArrayList (java.util.ArrayList)1 Arrays.asList (java.util.Arrays.asList)1 EnumMap (java.util.EnumMap)1 List (java.util.List)1 DynamicNode (org.junit.jupiter.api.DynamicNode)1 DynamicTest (org.junit.jupiter.api.DynamicTest)1 Test (org.junit.jupiter.api.Test)1 Details (org.junit.platform.console.options.Details)1