He is everything! My tests are run by jenkins from a common package. Can I install a test package in spock, which will be launched first, and if no test passes in this package, other tests should be skipped. I saw such examples:
import org.junit.runner.RunWith; import org.junit.runners.Suite; @RunWith(Suite.class) @Suite.SuiteClasses({TestJunit1.class, TestJunit2.class}) public class JunitTestSuite { }
But maybe spock has a solution where I can use packages instead of enum for each class, because I have many test classes in other packages. Also after i used the runner
import org.junit.runner.JUnitCore; import org.junit.runner.Result; import org.junit.runner.notification.Failure; public class TestRunner { public static void main(String[] args) { Result result = JUnitCore.runClasses(JunitTestSuite.class); for (Failure failure : result.getFailures()) { System.out.println(failure.toString()); } System.out.println(result.wasSuccessful()); } }
The main thread does not stop. I do not know why. I want to do something like this:
import org.junit.runner.RunWith; import org.junit.runners.Suite; @RunWith(Suite.class) @Suite.SuiteClasses({com.example.test.*.class}) public class JunitTestSuiteFirst { }
import org.junit.runner.RunWith; import org.junit.runners.Suite; @RunWith(Suite.class) @Suite.SuiteClasses({com.example.otherTest.*.class, com.example.otherTests2.*.class}) public class JunitTestSuiteFirst { }
import org.junit.runner.JUnitCore; import org.junit.runner.Result; import org.junit.runner.notification.Failure; public class TestRunner { public static void main(String[] args) { Result result = JUnitCore.runClasses(JunitTestSuite.class); for (Failure failure : result.getFailures()) { System.out.println(failure.toString()); } if(result.wasSuccessful()){ JUnitCore.runClasses(JunitTestSuite.class); }else { System.out.println("Build failed"); } } }
Or maybe there is a simpler solution to this problem. Thanks.
source share