系统信息:操作系统:Win XP (32bit) Selenium Webdriver:3.32 Firefox:20.0 Junit:4.0 Eclipse:3.8
我的测试项目下有两个 JUnit(4.0) 上的测试脚本文件。这些文件工作正常。
我有一个问题,我想制作一个主脚本文件,将我的所有测试脚本文件调用到其中。1. GooglePageTest.java有 5 个按预期运行的测试函数。
2. TestGoogleApp.java有 8 个测试函数,按预期运行。
3.现在我有一个主脚本文件( MainTest.java ),它调用GooglePageTest 和TestGoogleApp 形式的一些函数。请提供我如何做到这一点的解决方案。我尝试在 MainTest.java 文件中添加一些代码,请参阅以下代码供您参考:
import org.junit.Before;
public class MainTest
{
public GoogalePageTest test;
public TestGoogleApp test2;
@Before
public void setUP()
{
test = new GoogalePageTest();
test2 = new TestGoogleApp();
}
//@Test
public void test()
{
try{
// This line call all the test function from the GooglPageTest file,
// rather than one function.
test.Googletest01(); //Run only this test function
//test.Googletest02(); //Do not run this test function
//Run this test only from the test script TestGoogleApp
test2.WebTest02();
}catch(Exception e)
{
e.printStackTrace();
System.out.println(" Error description: " + e);
}
}
}
但是当我尝试运行此代码时,它会从 GoogalePageTest 文件中调用所有测试函数。
你能帮我解决这个问题吗?
任何帮助或建议都是可观的。
您可以在这里给我您的建议,或者通过 niraj06.srivastava@gmail.com 将您的建议或问题/疑虑邮寄给我
提前致谢
问候 Neeraj S