I’ve been using plugin test runner 2.0.0 for a while and wanted to upgrade to 2.0.2 (so I can use JUnit 4.12). My current dependencies in pom.xml include:
<dependency>
<groupId>com.atlassian.plugins</groupId>
<artifactId>atlassian-plugins-osgi-testrunner</artifactId>
<version>2.0.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
However, it started failing, complaining that the @BeforeClass
methods should be static.
For example, my test looks like this:
@RunWith(AtlassianPluginsTestRunner.class)
public class CanaryITest {
@BeforeClass
public void sayHello() {
System.out.println("Hello, world");
}
@Test
public void testCanary() {
assertThat(true).isTrue();
}
}
Now it’s crashing with (executing from IntelliJ IDEA):
java.lang.Exception: Method sayHello() should be static
at org.junit.runners.model.FrameworkMethod.validatePublicVoid(FrameworkMethod.java:93)
at org.junit.runners.model.FrameworkMethod.validatePublicVoidNoArg(FrameworkMethod.java:74)
at org.junit.runners.ParentRunner.validatePublicVoidNoArgMethods(ParentRunner.java:155)
at org.junit.runners.ParentRunner.collectInitializationErrors(ParentRunner.java:125)
at org.junit.runners.BlockJUnit4ClassRunner.collectInitializationErrors(BlockJUnit4ClassRunner.java:124)
at org.junit.runners.ParentRunner.validate(ParentRunner.java:416)
at org.junit.runners.ParentRunner.<init>(ParentRunner.java:84)
at org.junit.runners.BlockJUnit4ClassRunner.<init>(BlockJUnit4ClassRunner.java:65)
at com.atlassian.plugins.osgi.test.AtlassianPluginsTestRunner.<init>(AtlassianPluginsTestRunner.java:59)
The only documentation I found is clearly outdated: https://developer.atlassian.com/server/framework/atlassian-sdk/run-wired-tests-with-the-plugin-test-console/.
Am I doing something wrong, or did this just break with PTR 2.0.2? What is the lifecycle of these tests today - does it match JUnit, with static @BeforeClass
, followed by constructor, followed by non-static @Before
?