I have a robolectric unit test that is work in progress. I want to disable it temporarily pending implementation, but I don't want to comment out the entire test.
How can a robolectric unit test be temporarily disabled without actually removing the test?
The downside is that it fakes an Android environment which you should be aware of. To validate real world problems, better use a classic Android Framework approach. The best is still to write your code in a way that you can unit test it and that you don't need a context or any other Android framework dependencies.
setupActivity() is deprecated in Android unit test. Save this question.
Mockito is used for mocking the dependency which means if you want to access an real object in test environment then you need to fake it or we can say mock it. Now a days it is very easier to do mocking of the objects with Mockito. Roboelectric is the industry-standard unit testing framework for Android.
The JUnit @Ignore
attribute can be used to temporarily disable a unit test:
@RunWith(MyRobolectricGradleTestRunner.class)
public class TestAbc123 extends MyTestBase
{
@Ignore // This attribute may be removed once the test is ready
@Test
public void TestAbc123Scenerio1()
{
Ignored tests are shown as an amber disc with horizontal bars:
To ignore a Unit test, annotate it with @Ignore
.
You can add an optional comment to record why the test is being ignored:
@Ignore("Not ready yet")
@Test
public void testToIgnore()
{
// ...
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With