如何将TestNG集成到Android项目中?(How do I integrate TestNG into an Android project?)

编程入门 行业动态 更新时间:2024-10-28 05:27:27
如何将TestNG集成到Android项目中?(How do I integrate TestNG into an Android project?)

那些人的简短问题。

如果我从头开始,我究竟如何将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

更多推荐

本文发布于:2023-08-03 00:00:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1382528.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何将   项目   TestNG   Android   integrate

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!