Disallow annotating a non-static method with @BeforeClass
- Dominant language
- Java
- Stars
- 7.2k
- Forks
- 820
- Avg merge
- 5h 9m
- Merged PRs (30d)
- 50
Description
_[Original issue](https://code.google.com/p/error-prone/issues/detail?id=25) created by **eaftan@google.com** on 2012-07-16 at 07:18 PM_
---
The JUnit @BeforeClass annotation should only be applied to a public static void no-arg method, otherwise it throws a runtime error. We should detect this at compile time.
There may also be other JUnit-specific checks we can write. For example, JUnit doesn't run tests that are not marked public. This can cause someone to mistakenly think that their newly created tests are runnign when they're actually not. Some other reason tests weren't being run:
- The test class did not extend TestCase
- The test method wasn't public
- The test method didn't start with "test" (e.g. tesSomething)
- The test method took a parameter
Contributor guide
Assessment
This issue has not been assessed yet.