Problems with @Rule in junit-test

Hi all, I have this test and it seems the @Rule is not working:

@RunWith(classOf[SpringRunner])
@SpringBootTest(args = Array("--help")
	, properties = Array("database.hostName=localhost", "database.databaseName=visena", "database.userName=visena"
		, "database.password=na"))
class ApplicationTest {

	@Autowired
	val application: Application = null

	@Test
	@throws[Exception]
	def runUpgrade() = {
		println("Starting test...")
		application.run("--all", "--showinfo")
		Assert.assertThat(outputCapture.getOut, containsString("OK - DATABASE update DONE, last_updated"))
		application.run("--all")
		application.run("--showinfo")
	}

	@Rule
	var outputCapture = new OutputCaptureRule

}

When running the test I get this error:

org.junit.internal.runners.rules.ValidationError: The @Rule 'outputCapture' must be public.

	at org.junit.internal.runners.rules.RuleMemberValidator$MemberMustBePublic.validate(RuleMemberValidator.java:222)
	at org.junit.internal.runners.rules.RuleMemberValidator.validateMember(RuleMemberValidator.java:99)
	at org.junit.internal.runners.rules.RuleMemberValidator.validate(RuleMemberValidator.java:93)
	at org.junit.runners.BlockJUnit4ClassRunner.validateFields(BlockJUnit4ClassRunner.java:196)
	at org.junit.runners.BlockJUnit4ClassRunner.collectInitializationErrors(BlockJUnit4ClassRunner.java:129)
	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 org.springframework.test.context.junit4.SpringJUnit4ClassRunner.<init>(SpringJUnit4ClassRunner.java:137)
	at org.springframework.test.context.junit4.SpringRunner.<init>(SpringRunner.java:49)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481)
	at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:104)

Any ideas why outputCapture isn’t public?

If I change it to

	@(Rule @getter)
	var outputCapture = new OutputCaptureRule

The test runs but it seems it isn’t treated as a @Rule, and outputCapture.getOut returns empty-string “”

Any ideas?