Commit ea66d8355f4bf9b19c810d6530546bb63cffd515

Authored by Paulo Graça
1 parent bf921e846b
Exists in tests

MainTester

ptcrisync-test/src/main/java/pt/ptcris/test/main/MainTester.java
... ... @@ -0,0 +1,47 @@
  1 +package pt.ptcris.test.main;
  2 +
  3 +import org.junit.runner.JUnitCore;
  4 +import org.junit.runner.Result;
  5 +import org.junit.runner.notification.Failure;
  6 +import org.apache.commons.cli.CommandLine;
  7 +import org.apache.commons.cli.CommandLineParser;
  8 +import org.apache.commons.cli.DefaultParser;
  9 +import org.apache.commons.cli.Option;
  10 +import org.apache.commons.cli.Options;
  11 +import org.apache.commons.cli.ParseException;
  12 +
  13 +import pt.ptcris.test.preparation.WorkTestPrepare;
  14 +
  15 +public class MainTester {
  16 +
  17 + public static void main(String[] args) {
  18 + Option prepare = new Option( "prepare", "execute preparing files prior testing, it will"
  19 + + "download files based on public.properties configuration file." );
  20 +
  21 + Options options = new Options();
  22 + options.addOption( prepare );
  23 +
  24 + try {
  25 +
  26 + CommandLineParser parser = new DefaultParser();
  27 + CommandLine cmd = parser.parse( options, args);
  28 +
  29 + if(cmd.hasOption("prepare")) {
  30 + WorkTestPrepare.main(args);
  31 + }
  32 + else {
  33 + Result result = JUnitCore.runClasses(PTCRISTestSuite.class);
  34 + for (Failure failure : result.getFailures()) {
  35 + System.out.println(failure.toString());
  36 + }
  37 + System.out.println(result.wasSuccessful());
  38 + }
  39 +
  40 + }
  41 + catch( ParseException exp ) {
  42 + // oops, something went wrong
  43 + System.err.println( "Parsing failed. Reason: " + exp.getMessage() );
  44 + }
  45 +
  46 + }
  47 +}
... ...
ptcrisync-test/src/main/java/pt/ptcris/test/main/PTCRISTestSuite.java
... ... @@ -0,0 +1,16 @@
  1 +package pt.ptcris.test.main;
  2 +
  3 +import org.junit.runner.RunWith;
  4 +import org.junit.runners.Suite;
  5 +
  6 +import pt.ptcris.test.IntegrationTest;
  7 +import pt.ptcris.test.PerformanceTest;
  8 +
  9 +@RunWith(Suite.class)
  10 +@Suite.SuiteClasses({
  11 + IntegrationTest.class, PerformanceTest.class
  12 +})
  13 +public class PTCRISTestSuite {
  14 + // the class remains empty,
  15 + // used only as a holder for the above annotations
  16 +}
... ...