Skip to content
New issue

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

Ignore by default all tests with org.junit.Ignore annotation #186

Closed
CristianGM opened this issue Feb 25, 2019 · 8 comments · Fixed by #226
Closed

Ignore by default all tests with org.junit.Ignore annotation #186

CristianGM opened this issue Feb 25, 2019 · 8 comments · Fixed by #226
Assignees
Labels
bug Something isn't working
Milestone

Comments

@CristianGM
Copy link

Tests annotated with ignore will cause an infinite loop if not ignored, to prevent that we could ignore them by default on the Gradle Plugin.

@tagantroy
Copy link
Member

tagantroy commented Feb 26, 2019

@CristianGM Can you reproduce it on sample project?

Device pool omni: 24 passed, 0 failed, 2 ignored tests

on latest develop branch it works as expected

@lukaville
Copy link
Contributor

lukaville commented Mar 21, 2019

We also have the same problem, it doesn't hang with blacklisted org.junit.Ignore annotation

@lukaville
Copy link
Contributor

@tagantroy
Looks like it's happening when you place @Ignore annotation on the class, not the test method.

@CristianGM
Copy link
Author

I had the same issue with the annotation on the method and the class.
I thought the reason was that the method had more than one annotation and maybe the plugin was looking just for the first annotation.

@tagantroy
Copy link
Member

tagantroy commented Apr 2, 2019

https://github.com/Malinskiy/marathon/tree/reproduce_problem_with_Ignore_on_class.
I reproduced this problem and found interesting logs

java.lang.NullPointerException: Attempt to invoke interface method 'int java.lang.CharSequence.length()' on a null object reference
at java.util.regex.Matcher.reset(Matcher.java:995)
at java.util.regex.Matcher.<init>(Matcher.java:174)
at java.util.regex.Pattern.matcher(Pattern.java:1006)
at android.support.test.internal.runner.TestRequestBuilder$MethodFilter.stripParameterizedSuffix(TestRequestBuilder.java:524)
at android.support.test.internal.runner.TestRequestBuilder$MethodFilter.evaluateTest(TestRequestBuilder.java:510)
at android.support.test.internal.runner.TestRequestBuilder$ParentFilter.shouldRun(TestRequestBuilder.java:145)
at android.support.test.internal.runner.TestRequestBuilder$ClassAndMethodFilter.evaluateTest(TestRequestBuilder.java:452)
at android.support.test.internal.runner.TestRequestBuilder$ParentFilter.shouldRun(TestRequestBuilder.java:145)
at org.junit.runner.manipulation.Filter$3.shouldRun(Filter.java:112)
at org.junit.runners.ParentRunner.shouldRun(ParentRunner.java:434)
at org.junit.runners.ParentRunner.filter(ParentRunner.java:382)
at org.junit.runner.manipulation.Filter.apply(Filter.java:97)
at android.support.test.internal.runner.TestRequestBuilder$LenientFilterRequest.getRunner(TestRequestBuilder.java:413)
at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
at android.support.test.internal.runner.TestExecutor.execute(TestExecutor.java:58)
at android.support.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:375)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1932)

I also found this issue jaredsburrows/gradle-spoon-plugin#47

@tagantroy tagantroy added the bug Something isn't working label Apr 3, 2019
@tagantroy tagantroy added this to the 0.5.0 milestone Apr 3, 2019
@Malinskiy
Copy link
Member

We're going to check the Ignored tests after parsing all the tests from vendor module during the init phase and we're going the create a fake report for these, because real test runner doesn't behave as expected.

@Malinskiy Malinskiy self-assigned this Apr 13, 2019
@Malinskiy
Copy link
Member

Malinskiy commented May 11, 2019

I've checked the implementation of the Android test runner and found other ways to ignore the test but using the @Suppress for example will not report the test at all

The problematic bit in the runner is checking if something is a test or not. The logic is that it's a test if there are no children in object tree and that usually happens, but in this case this condition is also true for the whole class and then the parameterized logic crashes because it assumes that it's input is CLASS#METHOD but in reality it's just CLASS and hence NPE for the method part

@Malinskiy
Copy link
Member

Malinskiy commented May 11, 2019

The reason why it is considered a test is because the runner implementation that is used in case of ignored class is IgnoredClassRunner compared to the usual Suite. The difference is that Suite actually returns children for the class node hence the isTest passes properly

IgnoredClassRunner
Suite

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants