You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When creating an instrumented test with @DisplayName, e.g.:
@Test
@DisplayName("displayName's display name")
public void displayName() { assertTrue(true); }
Attempting to run the test individually (via either IDE or command line) will error with: No tests found. This usually means that your test classes are not in the form that your test runner expects (e.g. don't inherit from TestCase or lack @Test annotations).
Running the test from the class-level or higher will work as expected. The same test will also be runnable individually if it is a unit rather than android test.
Also note that @ParameterizedTest's do not have this issue when given a display name (which makes sense since they already involve display names afaik).
I have the same problem. I've noticed that replacing Test annotations with junit4 ones (replace org.junit.jupiter.api.Test with org.junit.Test) allows individual instrumented tests to run, both from IDE and command line. Running tests in a whole class works fine too (as long as there are no @nested classes). This is definitely not a solid workaround, as it breaks tests in @nested classes, but it might be a clue for contributors when working on a fix.
Another interesting observation, in test class with two tests (no @nested classes), if both have same @test annotations (either both @org.junit.jupiter.api.Test or both @org.junit.Test) then running all tests in a class runs both of them, but when they're mixed, only @org.junit.jupiter.api.Test runs.
public class ExampleTest {
@BeforeEach
public void setUp() {
}
// when running all tests in a class, this will run
@DisplayName("test 1")
@org.junit.jupiter.api.Test
public void test1() {
}
// but this will not
@DisplayName("test 2")
@org.junit.Test
public void test2() {
}
The ability to assign a @DisplayName to a test is hindering the interoperability when running a test in isolation, because the association to the original method is lost when it is mapped to the old-style world that Android's instrumentation is confined to. (This is actually very related to #199 in that sense!)
For the upcoming 1.3.0 release, you will be able to execute individual tests with @DisplayName correctly, but they will lose their formatting and fall back to the actual method name in the process. When they run together, the pretty name is retained, but they will lose it in isolation - that's a limitation of the instrumentation that we have to obey.
When creating an instrumented test with
@DisplayName
, e.g.:Attempting to run the test individually (via either IDE or command line) will error with:
No tests found. This usually means that your test classes are not in the form that your test runner expects (e.g. don't inherit from TestCase or lack @Test annotations).
Running the test from the class-level or higher will work as expected. The same test will also be runnable individually if it is a unit rather than android test.
Also note that
@ParameterizedTest
's do not have this issue when given a display name (which makes sense since they already involve display names afaik).Env info:
android-junit5 plugin 1.5.2.0
mannodermaus.junit5 1.2.0
junit 5.5.2
androidx.test 1.2.0
gradle 6.2.1
android gradle 3.5.3
The text was updated successfully, but these errors were encountered: