Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Test testPreconditions

In Android developers I've seen that testPreconditions() method is supposed to be launch before all tests. But in my app test, it's acting like a normal test. It does not run before all tests. Is there something wrong ?

Here is the description about testPreconditions() from android developer : "A preconditions test checks the initial application conditions prior to executing other tests. It's similar to setUp(), but with less overhead, since it only runs once."

like image 641
manshuai Avatar asked Mar 25 '12 10:03

manshuai


2 Answers

Actually, testPreconditions() is just another unit test. Here is a quote from "Android Application Testing Guide", a book by Diego Torres Milano:

"The testPreconditions method This method is used to check for some initial conditions to run our tests correctly. Despite its name, it is not guaranteed that this test is run before other tests. However, it is a good practice to collect all of the precondition tests under this custom name."

Milano, Diego Torres (2011-06-23). Android Application Testing Guide (p. 76). Packt Publishing. Kindle Edition.

like image 99
Chuck Krutsinger Avatar answered Oct 20 '22 12:10

Chuck Krutsinger


According to Android SDK samples:

   The name 'test preconditions' is a convention to signal that if this
   test doesn't pass, the test case was not set up properly and it might
   explain any and all failures in other tests.  This is not guaranteed
   to run before other tests, as junit uses reflection to find the tests.
like image 26
IgorGanapolsky Avatar answered Oct 20 '22 11:10

IgorGanapolsky