Isolated test environment in projects that using sugar


To allow isolated test environment in projects that using sugar:

1. Detect if Android application is running inside a unit test
2. Use different database name for testing environment (keep intact develop database)
3. Allow drop test database
4. Duplicate develop database for tests 

To reset database before each test.


	public class BarTest extends TestCase {

	     @Override
	     @Before
	     public void setUp() throws Exception {
	          SugarDb.dropTestDatabase();
	     }

	     @Test
	     public void testFeature1() {
	       ...
	     }

	     @Test
	     public void testFeature2() {
	       ...
	     }
	}



To duplicate develop database for before each test.

	public class BarTest extends TestCase {

	     @Override
	     @Before
	     public void setUp() throws Exception {
	          SugarDb.prepareTestDatabase();
	     }

	     @Override
	     @After
	     public void tearDown() throws Exception {
	          SugarDb.dropTestDatabase();
	     }

	     @Test
	     public void testFeature1() {
	       ...
	     }

	     @Test
	     public void testFeature2() {
	       ...
	     }
	}