You can use the SilkTestCategories class to run Silk4J tests, write TrueLogs, and filter or group tests with annotations. Define categories of test classes to group the Silk4J tests into these categories, and to run only the tests that are included in a specified category or a subtype of that category. For additional information, see Grouping tests using JUnit categories.
To include a Silk4J test in a category, use the @IncludeCategory annotation.
Using the category SilkTestCategories class enables you to write TrueLogs for the Silk4J tests included in the category. You can also use the SilkTestSuite class to write TrueLogs. For additional information, see Replaying a Test Method from the Command Line.
The following example shows how you can execute the Silk4J tests that are included in a category.
import org.junit.experimental.categories.Category;
public interface FastTests {} public interface SlowTests {}
@Category( { SlowTests.class}) public class A { @Test public void a() { ... } @Test public void b() { ... } }
public class B { @Test public void c() { ... } @Category(FastTests.class) @Test public void d() { ... } }
@Category( { SlowTests.class, FastTests.class }) public static class C { @Test public void e() { ... } }
@RunWith(SilkTestCategories.class) @IncludeCategory(SlowTests.class) @SuiteClasses( { A.class, C.class }) // Note: SilkTestCategories is a kind of Suite public static class SlowTestSuite {}