Reputation: 2376
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
Upvotes: 4
Views: 5913
Reputation: 1
You just have to add the below dependencies to your gradle file:
androidTestCompile 'org.assertj:assertj-core:2.0.0'
androidTestCompile 'org.testng:testng:6.9.10'
Upvotes: 0
Reputation: 306
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
Upvotes: 2