Quantcast
Channel: Gradle Forums - Latest posts
Viewing all articles
Browse latest Browse all 19888

Using org.gradle.api.tasks.testing.Test.beforeTest in java

$
0
0

The beforeTest(Closure) method is just a shortcut you can use in Groovy. Ultimately, it maps the closure to receive broadcasts the same as the TestListener interface. You can clean up how you handle this vs. using the anonymous class, but essentially:

test.addTestListener(new TestListener() {
    void beforeSuite(TestDescriptor suite) {}
    void afterSuite(TestDescriptor suite, TestResult result) {}
    void beforeTest(TestDescriptor testDescriptor) {
        println("Starting " + testDescriptor.toString());
    }
    void afterTest(TestDescriptor testDescriptor, TestResult result) {}
});

Viewing all articles
Browse latest Browse all 19888

Trending Articles