org.gradle.api.tasks.testing.logging.TestLogging Java Examples

The following examples show how to use org.gradle.api.tasks.testing.logging.TestLogging. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Test.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private TestExceptionFormatter getExceptionFormatter(TestLogging testLogging) {
    switch (testLogging.getExceptionFormat()) {
        case SHORT:
            return new ShortExceptionFormatter(testLogging);
        case FULL:
            return new FullExceptionFormatter(testLogging);
        default:
            throw new AssertionError();
    }
}
 
Example #2
Source File: Test.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private TestExceptionFormatter getExceptionFormatter(TestLogging testLogging) {
    switch (testLogging.getExceptionFormat()) {
        case SHORT:
            return new ShortExceptionFormatter(testLogging);
        case FULL:
            return new FullExceptionFormatter(testLogging);
        default:
            throw new AssertionError();
    }
}
 
Example #3
Source File: Test.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private TestExceptionFormatter getExceptionFormatter(TestLogging testLogging) {
    switch (testLogging.getExceptionFormat()) {
        case SHORT:
            return new ShortExceptionFormatter(testLogging);
        case FULL:
            return new FullExceptionFormatter(testLogging);
        default:
            throw new AssertionError();
    }
}
 
Example #4
Source File: Test.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private TestExceptionFormatter getExceptionFormatter(TestLogging testLogging) {
    switch (testLogging.getExceptionFormat()) {
        case SHORT:
            return new ShortExceptionFormatter(testLogging);
        case FULL:
            return new FullExceptionFormatter(testLogging);
        default:
            throw new AssertionError();
    }
}
 
Example #5
Source File: ShortExceptionFormatter.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public ShortExceptionFormatter(TestLogging testLogging) {
    this.testLogging = testLogging;
}
 
Example #6
Source File: Test.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@TaskAction
public void executeTests() {
    LogLevel currentLevel = getCurrentLogLevel();
    TestLogging levelLogging = testLogging.get(currentLevel);
    TestExceptionFormatter exceptionFormatter = getExceptionFormatter(levelLogging);
    TestEventLogger eventLogger = new TestEventLogger(getTextOutputFactory(), currentLevel, levelLogging, exceptionFormatter);
    addTestListener(eventLogger);
    addTestOutputListener(eventLogger);
    if (!getFilter().getIncludePatterns().isEmpty()) {
        addTestListener(new NoMatchingTestsReporter("No tests found for given includes: " + getFilter().getIncludePatterns()));
    }

    File binaryResultsDir = getBinResultsDir();
    getProject().delete(binaryResultsDir);
    getProject().mkdir(binaryResultsDir);

    Map<String, TestClassResult> results = new HashMap<String, TestClassResult>();
    TestOutputStore testOutputStore = new TestOutputStore(binaryResultsDir);

    TestOutputStore.Writer outputWriter = testOutputStore.writer();
    TestReportDataCollector testReportDataCollector = new TestReportDataCollector(results, outputWriter);

    addTestListener(testReportDataCollector);
    addTestOutputListener(testReportDataCollector);

    TestCountLogger testCountLogger = new TestCountLogger(getProgressLoggerFactory());
    addTestListener(testCountLogger);

    TestResultProcessor resultProcessor = new TestListenerAdapter(
            getTestListenerBroadcaster().getSource(), testOutputListenerBroadcaster.getSource());

    if (testExecuter == null) {
        testExecuter = new DefaultTestExecuter(getProcessBuilderFactory(), getActorFactory());
    }

    try {
        testExecuter.execute(this, resultProcessor);
    } finally {
        testExecuter = null;
        testListenerBroadcaster.removeAll();
        testOutputListenerBroadcaster.removeAll();
        outputWriter.close();
    }

    new TestResultSerializer(binaryResultsDir).write(results.values());

    TestResultsProvider testResultsProvider = new InMemoryTestResultsProvider(results.values(), testOutputStore.reader());

    try {
        if (testReporter == null) {
            testReporter = new DefaultTestReport();
        }

        JUnitXmlReport junitXml = reports.getJunitXml();
        if (junitXml.isEnabled()) {
            TestOutputAssociation outputAssociation = junitXml.isOutputPerTestCase()
                    ? TestOutputAssociation.WITH_TESTCASE
                    : TestOutputAssociation.WITH_SUITE;
            Binary2JUnitXmlReportGenerator binary2JUnitXmlReportGenerator = new Binary2JUnitXmlReportGenerator(junitXml.getDestination(), testResultsProvider, outputAssociation);
            binary2JUnitXmlReportGenerator.generate();
        }

        DirectoryReport html = reports.getHtml();
        if (!html.isEnabled()) {
            getLogger().info("Test report disabled, omitting generation of the HTML test report.");
        } else {
            testReporter.generateReport(testResultsProvider, html.getDestination());
        }
    } finally {
        CompositeStoppable.stoppable(testResultsProvider).stop();
        testReporter = null;
        testFramework = null;
    }

    if (testCountLogger.hadFailures()) {
        handleTestFailures();
    }
}
 
Example #7
Source File: TestEventLogger.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public TestEventLogger(StyledTextOutputFactory textOutputFactory, LogLevel logLevel, TestLogging testLogging, TestExceptionFormatter exceptionFormatter) {
    super(textOutputFactory, logLevel, testLogging.getDisplayGranularity());
    this.exceptionFormatter = exceptionFormatter;
    this.testLogging = testLogging;
}
 
Example #8
Source File: FullExceptionFormatter.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public FullExceptionFormatter(TestLogging testLogging) {
    this.testLogging = testLogging;
}
 
Example #9
Source File: Test.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@TaskAction
public void executeTests() {
    LogLevel currentLevel = getCurrentLogLevel();
    TestLogging levelLogging = testLogging.get(currentLevel);
    TestExceptionFormatter exceptionFormatter = getExceptionFormatter(levelLogging);
    TestEventLogger eventLogger = new TestEventLogger(textOutputFactory, currentLevel, levelLogging, exceptionFormatter);
    addTestListener(eventLogger);
    addTestOutputListener(eventLogger);
    if (!getFilter().getIncludePatterns().isEmpty()) {
        addTestListener(new NoMatchingTestsReporter("No tests found for given includes: " + getFilter().getIncludePatterns()));
    }

    File binaryResultsDir = getBinResultsDir();
    getProject().delete(binaryResultsDir);
    getProject().mkdir(binaryResultsDir);

    Map<String, TestClassResult> results = new HashMap<String, TestClassResult>();
    TestOutputStore testOutputStore = new TestOutputStore(binaryResultsDir);

    TestOutputStore.Writer outputWriter = testOutputStore.writer();
    TestReportDataCollector testReportDataCollector = new TestReportDataCollector(results, outputWriter);

    addTestListener(testReportDataCollector);
    addTestOutputListener(testReportDataCollector);

    TestCountLogger testCountLogger = new TestCountLogger(progressLoggerFactory);
    addTestListener(testCountLogger);

    TestResultProcessor resultProcessor = new TestListenerAdapter(
            getTestListenerBroadcaster().getSource(), testOutputListenerBroadcaster.getSource());

    try {
        testExecuter.execute(this, resultProcessor);
    } finally {
        testListenerBroadcaster.removeAll();
        testOutputListenerBroadcaster.removeAll();
        outputWriter.close();
    }

    new TestResultSerializer(binaryResultsDir).write(results.values());

    TestResultsProvider testResultsProvider = new InMemoryTestResultsProvider(results.values(), testOutputStore.reader());

    try {
        JUnitXmlReport junitXml = reports.getJunitXml();
        if (junitXml.isEnabled()) {
            TestOutputAssociation outputAssociation = junitXml.isOutputPerTestCase()
                    ? TestOutputAssociation.WITH_TESTCASE
                    : TestOutputAssociation.WITH_SUITE;
            Binary2JUnitXmlReportGenerator binary2JUnitXmlReportGenerator = new Binary2JUnitXmlReportGenerator(junitXml.getDestination(), testResultsProvider, outputAssociation);
            binary2JUnitXmlReportGenerator.generate();
        }

        DirectoryReport html = reports.getHtml();
        if (!html.isEnabled()) {
            getLogger().info("Test report disabled, omitting generation of the HTML test report.");
        } else {
            testReporter.generateReport(testResultsProvider, html.getDestination());
        }
    } finally {
        CompositeStoppable.stoppable(testResultsProvider).stop();
    }

    testFramework = null;

    if (testCountLogger.hadFailures()) {
        handleTestFailures();
    }
}
 
Example #10
Source File: ShortExceptionFormatter.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public ShortExceptionFormatter(TestLogging testLogging) {
    this.testLogging = testLogging;
}
 
Example #11
Source File: TestEventLogger.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public TestEventLogger(StyledTextOutputFactory textOutputFactory, LogLevel logLevel, TestLogging testLogging, TestExceptionFormatter exceptionFormatter) {
    super(textOutputFactory, logLevel, testLogging.getDisplayGranularity());
    this.exceptionFormatter = exceptionFormatter;
    this.testLogging = testLogging;
}
 
Example #12
Source File: FullExceptionFormatter.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public FullExceptionFormatter(TestLogging testLogging) {
    this.testLogging = testLogging;
}
 
Example #13
Source File: Test.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@TaskAction
public void executeTests() {
    LogLevel currentLevel = getCurrentLogLevel();
    TestLogging levelLogging = testLogging.get(currentLevel);
    TestExceptionFormatter exceptionFormatter = getExceptionFormatter(levelLogging);
    TestEventLogger eventLogger = new TestEventLogger(getTextOutputFactory(), currentLevel, levelLogging, exceptionFormatter);
    addTestListener(eventLogger);
    addTestOutputListener(eventLogger);
    if (!getFilter().getIncludePatterns().isEmpty()) {
        addTestListener(new NoMatchingTestsReporter("No tests found for given includes: " + getFilter().getIncludePatterns()));
    }

    File binaryResultsDir = getBinResultsDir();
    getProject().delete(binaryResultsDir);
    getProject().mkdir(binaryResultsDir);

    Map<String, TestClassResult> results = new HashMap<String, TestClassResult>();
    TestOutputStore testOutputStore = new TestOutputStore(binaryResultsDir);

    TestOutputStore.Writer outputWriter = testOutputStore.writer();
    TestReportDataCollector testReportDataCollector = new TestReportDataCollector(results, outputWriter);

    addTestListener(testReportDataCollector);
    addTestOutputListener(testReportDataCollector);

    TestCountLogger testCountLogger = new TestCountLogger(getProgressLoggerFactory());
    addTestListener(testCountLogger);

    TestResultProcessor resultProcessor = new TestListenerAdapter(
            getTestListenerBroadcaster().getSource(), testOutputListenerBroadcaster.getSource());

    if (testExecuter == null) {
        testExecuter = new DefaultTestExecuter(getProcessBuilderFactory(), getActorFactory());
    }

    try {
        testExecuter.execute(this, resultProcessor);
    } finally {
        testExecuter = null;
        testListenerBroadcaster.removeAll();
        testOutputListenerBroadcaster.removeAll();
        outputWriter.close();
    }

    new TestResultSerializer(binaryResultsDir).write(results.values());

    TestResultsProvider testResultsProvider = new InMemoryTestResultsProvider(results.values(), testOutputStore.reader());

    try {
        if (testReporter == null) {
            testReporter = new DefaultTestReport();
        }

        JUnitXmlReport junitXml = reports.getJunitXml();
        if (junitXml.isEnabled()) {
            TestOutputAssociation outputAssociation = junitXml.isOutputPerTestCase()
                    ? TestOutputAssociation.WITH_TESTCASE
                    : TestOutputAssociation.WITH_SUITE;
            Binary2JUnitXmlReportGenerator binary2JUnitXmlReportGenerator = new Binary2JUnitXmlReportGenerator(junitXml.getDestination(), testResultsProvider, outputAssociation);
            binary2JUnitXmlReportGenerator.generate();
        }

        DirectoryReport html = reports.getHtml();
        if (!html.isEnabled()) {
            getLogger().info("Test report disabled, omitting generation of the HTML test report.");
        } else {
            testReporter.generateReport(testResultsProvider, html.getDestination());
        }
    } finally {
        CompositeStoppable.stoppable(testResultsProvider).stop();
        testReporter = null;
        testFramework = null;
    }

    if (testCountLogger.hadFailures()) {
        handleTestFailures();
    }
}
 
Example #14
Source File: ErrorReportingTestListener.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
public ErrorReportingTestListener(TestLogging testLogging, Path spillDir, Path outputsDir, boolean verboseMode) {
   this.formatter = new FullExceptionFormatter(testLogging);
   this.spillDir = spillDir;
   this.outputsDir = outputsDir;
   this.verboseMode = verboseMode;
}
 
Example #15
Source File: ShortExceptionFormatter.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public ShortExceptionFormatter(TestLogging testLogging) {
    this.testLogging = testLogging;
}
 
Example #16
Source File: TestEventLogger.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public TestEventLogger(StyledTextOutputFactory textOutputFactory, LogLevel logLevel, TestLogging testLogging, TestExceptionFormatter exceptionFormatter) {
    super(textOutputFactory, logLevel, testLogging.getDisplayGranularity());
    this.exceptionFormatter = exceptionFormatter;
    this.testLogging = testLogging;
}
 
Example #17
Source File: FullExceptionFormatter.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public FullExceptionFormatter(TestLogging testLogging) {
    this.testLogging = testLogging;
}
 
Example #18
Source File: Test.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@TaskAction
public void executeTests() {
    LogLevel currentLevel = getCurrentLogLevel();
    TestLogging levelLogging = testLogging.get(currentLevel);
    TestExceptionFormatter exceptionFormatter = getExceptionFormatter(levelLogging);
    TestEventLogger eventLogger = new TestEventLogger(textOutputFactory, currentLevel, levelLogging, exceptionFormatter);
    addTestListener(eventLogger);
    addTestOutputListener(eventLogger);
    if (!getFilter().getIncludePatterns().isEmpty()) {
        addTestListener(new NoMatchingTestsReporter("No tests found for given includes: " + getFilter().getIncludePatterns()));
    }

    File binaryResultsDir = getBinResultsDir();
    getProject().delete(binaryResultsDir);
    getProject().mkdir(binaryResultsDir);

    Map<String, TestClassResult> results = new HashMap<String, TestClassResult>();
    TestOutputStore testOutputStore = new TestOutputStore(binaryResultsDir);

    TestOutputStore.Writer outputWriter = testOutputStore.writer();
    TestReportDataCollector testReportDataCollector = new TestReportDataCollector(results, outputWriter);

    addTestListener(testReportDataCollector);
    addTestOutputListener(testReportDataCollector);

    TestCountLogger testCountLogger = new TestCountLogger(progressLoggerFactory);
    addTestListener(testCountLogger);

    TestResultProcessor resultProcessor = new TestListenerAdapter(
            getTestListenerBroadcaster().getSource(), testOutputListenerBroadcaster.getSource());

    try {
        testExecuter.execute(this, resultProcessor);
    } finally {
        testListenerBroadcaster.removeAll();
        testOutputListenerBroadcaster.removeAll();
        outputWriter.close();
    }

    new TestResultSerializer(binaryResultsDir).write(results.values());

    TestResultsProvider testResultsProvider = new InMemoryTestResultsProvider(results.values(), testOutputStore.reader());

    try {
        JUnitXmlReport junitXml = reports.getJunitXml();
        if (junitXml.isEnabled()) {
            TestOutputAssociation outputAssociation = junitXml.isOutputPerTestCase()
                    ? TestOutputAssociation.WITH_TESTCASE
                    : TestOutputAssociation.WITH_SUITE;
            Binary2JUnitXmlReportGenerator binary2JUnitXmlReportGenerator = new Binary2JUnitXmlReportGenerator(junitXml.getDestination(), testResultsProvider, outputAssociation);
            binary2JUnitXmlReportGenerator.generate();
        }

        DirectoryReport html = reports.getHtml();
        if (!html.isEnabled()) {
            getLogger().info("Test report disabled, omitting generation of the HTML test report.");
        } else {
            testReporter.generateReport(testResultsProvider, html.getDestination());
        }
    } finally {
        CompositeStoppable.stoppable(testResultsProvider).stop();
    }

    testFramework = null;

    if (testCountLogger.hadFailures()) {
        handleTestFailures();
    }
}
 
Example #19
Source File: ShortExceptionFormatter.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public ShortExceptionFormatter(TestLogging testLogging) {
    this.testLogging = testLogging;
}
 
Example #20
Source File: TestEventLogger.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public TestEventLogger(StyledTextOutputFactory textOutputFactory, LogLevel logLevel, TestLogging testLogging, TestExceptionFormatter exceptionFormatter) {
    super(textOutputFactory, logLevel, testLogging.getDisplayGranularity());
    this.exceptionFormatter = exceptionFormatter;
    this.testLogging = testLogging;
}
 
Example #21
Source File: FullExceptionFormatter.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public FullExceptionFormatter(TestLogging testLogging) {
    this.testLogging = testLogging;
}