use of junit.extensions.TestSetup in project gradle by gradle.
the class SomeSuite method suite.
public static Test suite() {
final TestSuite suite = new TestSuite();
suite.addTestSuite(SomeTest1.class);
suite.addTestSuite(SomeTest2.class);
TestSetup wrappedSuite = new junit.extensions.TestSetup(suite) {
protected void setUp() {
System.out.println("stdout in TestSetup#setup");
System.err.println("stderr in TestSetup#setup");
}
protected void tearDown() {
System.out.println("stdout in TestSetup#teardown");
System.err.println("stderr in TestSetup#teardown");
}
};
return wrappedSuite;
}
use of junit.extensions.TestSetup in project jmeter by apache.
the class TestHTTPSamplersAgainstHttpMirrorServer method suite.
// This is used to emulate @before class and @after class
public static Test suite() {
final TestSuite testSuite = new TestSuite(TestHTTPSamplersAgainstHttpMirrorServer.class);
// Add parameterised tests. For simplicity we assume each has cases 0-10
for (int i = 0; i < 11; i++) {
testSuite.addTest(new TestHTTPSamplersAgainstHttpMirrorServer("itemised_testGetRequest_Parameters", i));
testSuite.addTest(new TestHTTPSamplersAgainstHttpMirrorServer("itemised_testGetRequest_Parameters3", i));
testSuite.addTest(new TestHTTPSamplersAgainstHttpMirrorServer("itemised_testPostRequest_UrlEncoded", i));
testSuite.addTest(new TestHTTPSamplersAgainstHttpMirrorServer("itemised_testPostRequest_UrlEncoded3", i));
}
TestSetup setup = new TestSetup(testSuite) {
private HttpMirrorServer httpServer;
@Override
protected void setUp() throws Exception {
httpServer = TestHTTPMirrorThread.startHttpMirror(MIRROR_PORT);
// Create the test file content
TEST_FILE_CONTENT = "some foo content &?=01234+56789-|⪡♪œ₡ĕͤÅ⁒쎅%C3%85".getBytes("UTF-8");
// create a temporary file to make sure we always have a file to give to the PostWriter
// Whereever we are or Whatever the current path is.
temporaryFile = File.createTempFile("TestHTTPSamplersAgainstHttpMirrorServer", "tmp");
OutputStream output = new FileOutputStream(temporaryFile);
output.write(TEST_FILE_CONTENT);
output.flush();
output.close();
}
@Override
protected void tearDown() throws Exception {
// Shutdown mirror server
httpServer.stopServer();
httpServer = null;
// delete temporay file
if (!temporaryFile.delete()) {
Assert.fail("Could not delete file:" + temporaryFile.getAbsolutePath());
}
}
};
return setup;
}
Aggregations