He,everyone! My tests are running by jenkins from general package. Can I set test package in spock which will be runnning first and if in this package will not passed any of test the other tests should be skipped. I saw examples like this:
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 solution where I can use packages instead enum of each classes, because I have many test classes in other many packages. Also after i used 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 doesnt stop. I dont know why. I want to do something like that:
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 exist more simple solution of this task. Thanks.
Aucun commentaire:
Enregistrer un commentaire