java - How do I customise my TestSuite tests in Junit 4? -


in code below, exampletest class contains 5 tests. however, want run 2 of them exampletestsuite class using junit.

public class exampletest extends testcase {     private example example;     public exampletest(string name) {         super(name);     }      protected void setup() throws exception {         super.setup();         example= new example();     }      protected void teardown() throws exception {         super.teardown();         example= null;     }      public void test1() {      }     public void test2() {      }     public void test3() {      }     public void test4() {      }     public void test5() {      }  } 

this code below done in junit 3, how do in junit version 4?

public class exampletestsuite {      public static test suite() {         testsuite suite = new testsuite(exampletestsuite.class.getname());         suite.addtest(new exampletest("test1"));         suite.addtest(new exampletest("test3"));         return (test) suite;     } } 

you can use categories runner introduced in junit 4.8 this:

/**  * marker class used @category annotation of junit.  */ public class smoketests {}   /**  * original test class converted junit 4.  */ public class exampletest {     private example example;      @before     public void setup() throws exception {         example = new example();     }      @after     public void teardown() throws exception {         example = null;     }      @test     @category(smoketests.class)     public void test1() {}      @test     public void test2() {}      @test     @category(smoketests.class)     public void test3() {}      @test     public void test4() {}      @test     public void test5() {} }   /**  * original test suite class converted junit 4.  */ @runwith(categories.class) @suiteclasses(exampletest.class) @includecategory(smoketests.class) public class exampletestsuite {} 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

html - Repeat image to extend header to fill screen -

javascript - Backbone.js getting target attribute -