We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When using a junit RunListener, it is expected that the order of events for a test with two @Test methods be:
@Test
However, with Robolectric (tested with 4.11.1) the first RunListener.testStarted is called before Test.setUp:
4.11.1
RunListener.testStarted
Add a RunListener that logs all methods, and run a test that contains a @BeforeClass that logs as well.
RunListener
@BeforeClass
Robolectric 4.11.1
A bit hard since my normal environment is a chrome checkout... Here's a paste of the test I used:
import java.io.FileOutputStream; import java.io.PrintStream; import org.junit.runner.Description; import org.junit.runner.notification.RunListener; // Mark this as doNotAcquire() so the PrintStream will work. public class ExampleTestListener extends RunListener { public static PrintStream PS; static { try { PS = new PrintStream(new FileOutputStream("/tmp/ffoo")); } catch (Exception e) { throw new RuntimeException(e); } } @Override public void testSuiteStarted(Description description) throws Exception { PS.println("testSuiteStarted " + description); } @Override public void testSuiteFinished(Description description) throws Exception { PS.println("testSuiteFinished " + description); } @Override public void testStarted(Description description) throws Exception { PS.println("testStarted " + description); } @Override public void testFinished(Description description) throws Exception { PS.println("testFinished " + description); } }
import org.junit.After; import org.junit.AfterClass; import org.junit.Assert; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; import org.robolectric.RobolectricTestRunner; import org.robolectric.annotation.Config; @RunWith(RobolectricTestRunner.class) @Config(manifest = Config.NONE) public class ExampleTest { @BeforeClass public static void setUpClass() { ExampleTestListener.PS.println("setUpClass"); } @AfterClass public static void tearDownClass() { ExampleTestListener.PS.println("tearDownClass"); } @Before public void setUp() { ExampleTestListener.PS.println("setUp"); } @After public void tearDown() { ExampleTestListener.PS.println("tearDown"); } @Test public void test1() { ExampleTestListener.PS.println("test1"); } @Test public void test2() { ExampleTestListener.PS.println("test2"); } }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Description
When using a junit RunListener, it is expected that the order of events for a test with two
@Test
methods be:However, with Robolectric (tested with
4.11.1
) the firstRunListener.testStarted
is called before Test.setUp:Steps to Reproduce
Add a
RunListener
that logs all methods, and run a test that contains a@BeforeClass
that logs as well.Robolectric & Android Version
Robolectric 4.11.1
Link to a public git repo demonstrating the problem:
A bit hard since my normal environment is a chrome checkout... Here's a paste of the test I used:
The text was updated successfully, but these errors were encountered: