那些人的简短问题。
如果我从头开始,我究竟如何将TestNG单元测试添加到现有的Android项目并运行它们?
我也使用IntelliJ(我不知道Maven Android)来运行测试。
谢谢
Short question for those folks out there.
If I am starting from scratch, how exactly do I add TestNG unit tests to my existing Android project along with running them?
I'm also using IntelliJ (I know not Maven Android) to run the tests.
Thanks
最满意答案
您可以使用testNG运行您想要的任何类型的测试用例。
您可以创建一个测试包,然后创建一个测试类来开始编写测试。 假设您的类名为AndroidTests.java,您需要导入testng并开始编写测试,如下所示:
@Test public void test1() { //Test logic here assert someAssert; }然后,当您有足够的测试用例时,您需要创建您的套件:
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" > <suite name="My smoke suite" verbose="1" > <test name="My android tests"> <classes> <class name="test.android.Androidtests"/> </classes> </test> </suite>最后从eclipse或使用命令行运行此套件。
请参阅testNG doc中的更多信息:
http://testng.org/doc/documentation-main.html
并且还看看Android测试文档:
http://developer.android.com/tools/testing/testing_android.html
You can use testNG to run any kind of test cases you want.
You can just create a test package, and then a test class to start writing your tests. Suppose that your class is called AndroidTests.java, you need to import testng and start writting your tests, just like this:
@Test public void test1() { //Test logic here assert someAssert; }Then, when you have enough test cases, you need to create your suite:
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" > <suite name="My smoke suite" verbose="1" > <test name="My android tests"> <classes> <class name="test.android.Androidtests"/> </classes> </test> </suite>And finally run this suite from eclipse or using command line.
Please refer to more info in testNG doc:
http://testng.org/doc/documentation-main.html
And also take a look to Android test documentation:
http://developer.android.com/tools/testing/testing_android.html
更多推荐
发布评论