Class and its test in different packages by default -> cannot access internal/protected members


#1

The project created by atlas-create-confluence-plugin comes with the example class MyPluginComponentImpl that resides in some package, let’s say test.impl. Then, the integration test MyComponentWiredTest for the class is in the package it.test. So, as the class is in another package, package internal and protected members cannot be accessed.

As tests should be put into the same package as the tested class (https://stackoverflow.com/questions/42255972/how-can-we-test-package-private-class) I moved MyComponentWiredTest to test.impl.

But then, when running the integration tests with atlas-integration-test I get the error:

test.impl.MyComponentWiredTest: the class [test.impl.MyComponentWiredTest] is annotated with @RunWith(AtlassianPluginsTestRunner.class) but it is not in the 'it.' package.(..)

How do you solve that? I don’t want to make everything public for testing. Of course I don’t want to move my implementation to it.test either.


#2

Ok, I guess the way to go for unit testing is to remove the default packages and tests created by the atlas-create-*-plugin command and create the tests in the same package as the implementation.

That, at least, seems to be what happended in this tutorial: https://developer.atlassian.com/server/framework/atlassian-sdk/getting-started-with-active-objects/

The tutorials says to use the atlas-create-refapp-plugin command. Checking out stage4 of the bitbucket project, however, confirms that the default test package ut.com.atlassian.* is not used.

Still, I don’t know how to handle integration tests as they are expected to be in the it.* package…