Skip to content

Instantly share code, notes, and snippets.

@coding963
Last active April 16, 2016 07:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save coding963/478b2c67a46d60f54095635cfd8fe232 to your computer and use it in GitHub Desktop.
Save coding963/478b2c67a46d60f54095635cfd8fe232 to your computer and use it in GitHub Desktop.
AllTestSuites
package com.test;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
@RunWith(Suite.class)
@SuiteClasses({TestOneSuite.class, TestTwoSuite.class})
public class AllTestSuites {
}
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.testsuite</groupId>
<artifactId>checktestsuite</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
package com.test;
import org.junit.Test;
public class TestClassOne {
@Test
public void testOne(){
System.out.println("Inside TestClassOne.");
}
}
package com.test;
import org.junit.Test;
public class TestClassTwo {
@Test
public void testTwo(){
System.out.println("Inside TestClassTwo.");
}
}
package com.test;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
@RunWith(Suite.class)
@SuiteClasses(TestClassOne.class)
public class TestOneSuite {
}
package com.test;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
@RunWith(Suite.class)
@SuiteClasses(TestClassTwo.class)
public class TestTwoSuite {
}
@coding963
Copy link
Author

Output on the console is:

Inside TestClassOne.
Inside TestClassTwo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment