I managed to transfer the Android project to JUnit4, and, of course, the main reason I wanted to do this does not work. Would love to have any help if anyone got ideas here.
The problem I'm trying to solve is that I want to automatically skip certain tests if the assembly is not listed on an intermediate server. I configured it using BUILD_TYPE , which uses gradle to enter the base URL.
I set the assumeThat clause in my setup, which correctly identifies when the build fails, but instead of stopping and ignoring the rest of the test, it throws an exception and fails.
Here is my base class for my live API tests - I annotated the descent from this with @RunWith(AndroidJUnit4.class) , so theoretically this should always be done with the JUnit4 runner:
package com.[my package].nonuitests.liveservertests; import android.support.test.runner.AndroidJUnit4; import com.[my package].nonuitests.BaseAndroidTest; import org.junit.Test; import org.junit.runner.RunWith; @RunWith(AndroidJUnit4.class) public class BaseLiveServerTests extends BaseAndroidTest { private static final String STAGE = "staging"; @Override public void setUp() throws Exception { super.setUp();
So my questions are:
- Is there a better way to do this? Theoretically, this could be done with the help of fragrances, but I tried to do it before, and it made everything more complicated.
- My research indicates that Google is not implementing in its runner what makes it bomb, but I get damn time to figure out what I can / should do to fix it. Any suggestions for things that I have to subclass in order to get this to work as expected?
Any other thoughts would be most appreciated. Thanks!
Edit (1/26/15 11:40 AM CST): Per Grzesuav's suggestion , I took a hit when implementing this as @Rule , but at the moment it still doesn't work. This seems like a promising way, but at the moment it is not working.
Edit 2 (1/26/15 12:15 pm CST): OK, now it works .
source share