I’m hoping someone can point me in the right direction for integration testing with TestKit, because I’m struggling against the lack of documentation / working examples.
In attempting to write the most basic skeleton test, I’m hitting up against a ComponentAccessor has not been initialised
error, but none of the material I have found online seems to address this issue in the context of TestKit.
Could someone explain what I am supposed to do instead of the (non-functional) example below? Any help greatly appreciated!
package it;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.project.Project;
import com.atlassian.jira.testkit.client.Backdoor;
import com.atlassian.jira.testkit.client.util.TestKitLocalEnvironmentData;
import com.atlassian.jira.testkit.client.util.TimeBombLicence;
import static org.junit.Assert.assertTrue;
import java.util.Set;
import org.junit.Test;
public class LgtmServletTest {
Backdoor testKit;
public LgtmServletTest() {
testKit = new Backdoor(new TestKitLocalEnvironmentData());
testKit.restoreBlankInstance(TimeBombLicence.LICENCE_FOR_TESTING);
testKit.usersAndGroups().addUser("test-user");
testKit.project().addProject("Testing Testing", "TT", "test-user");
}
@Test
public void testCreationOfProject() {
// interact with the plugin being tested
// resulting in creation of a ticket in project TT
Project project = ComponentAccessor.getProjectManager().getProjectByCurrentKey("TT");
Set<String> issueKeys = ComponentAccessor.getIssueManager().getAllIssueKeys(project.getId());
assertTrue( 0 < issueKeys.size() );
}
}