I am pretty new to java, still a lot learn. I have created an interface class called FailedTest. After all of the tests run, I would like to add the failed tests classes to the FailedTest interface class. Once I have all of the failed tests, I would like to create a gradle task to run all of the failed tests again. I am using Junit, Intellij and Gradle.
FailedTest interface class in categories package:------
package myPackage.categories;
public interface FailedTests {
}
TestExecutionListener in listeners:----------
@Category(FailedTests.class)
public void afterTestExecution(TestContext testContext) {
if (testContext.getTestException() != null) {
// i would like to add failed tests to the FailedTest interface class here
FailedTests = testContext.getTestClass();
}
}
In build.gradle I would like create following task:----------
task testFailedTests(type: Test) {ext.getTestMethodsFromStorage = { ->
//return a string array of the test classes/methods from the file:FailedTest
}
useJUnit {
include getTestMethodsFromStorage()
}
}
I would appreciate any help or feedback. Thank you!