Add main function to run an individual network stress test

This commit is contained in:
Ivan Vilata-i-Balaguer 2016-05-10 18:45:13 +02:00
parent 4b75235f33
commit 0fc8a1b5c0

View File

@ -23,6 +23,9 @@ import org.jetbrains.annotations.NotNull;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.JUnitCore;
import org.junit.runner.Request;
import org.junit.runner.Result;
import java.io.File;
import java.io.IOException;
@ -83,6 +86,16 @@ public class NetworkStressTest {
/** Number of direct messages to be sent by each peer. */
private int directCount = DIRECT_COUNT_DEFAULT;
// Inspired by <https://stackoverflow.com/a/9288513> by Marc Peters.
public static void main(String[] args) {
Request request = (args.length == 0)
? Request.aClass(NetworkStressTest.class)
: Request.method(NetworkStressTest.class, args[0]);
Result result = new JUnitCore().run(request);
System.exit(result.wasSuccessful() ? 0 : 1);
}
@Before
public void setUp() throws Exception {
// Parse test parameter environment variables.