我不希望Junit按順序調用我的測試方法/硒測試用例。但我想要執行特定的測試用例,或者根據需要調用它。如何自定義Junit的測試用例調用功能
示例代碼:
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import com.thoughtworks.selenium.DefaultSelenium;
import com.thoughtworks.selenium.Selenium;
public class demo2 {
Selenium selenium;
@Before
public void setUp() throws Exception {
selenium = new DefaultSelenium("localhost", 4444, "*firefox", "http://www.google.co.in/");
selenium.start();
selenium.setTimeout("6000");
}
@Test
public void test_3() throws Exception {
selenium.open("/");
selenium.type("q", "3");
}
@Test
public void test_4() throws Exception {
selenium.open("/");
selenium.type("q", "4");
}
@After
public void tearDown() throws Exception {
selenium.stop();
}
}
注意
我想的方法test_3,test_4 ....應視情況調用。