Testing with Arquillian - is @ExportAsService necessary?


While trying to write integration tests for my JIRA plugin I’ve encountered the following topic : https://community.developer.atlassian.com/t/integration-testing-in-jira-server/28497. It mentions testing with arquillian, so I tried it, and a got the most simple setup with test doing System.out.println working.

But when I try to import some class I want to test, for example :

@ComponentImport @Inject
private SomeClassToTest testClass;

I get an error like this :

java.lang.IllegalStateException: Error launching test it.MyFirstTest public void it.MyFirstTest.myTestMethod()
Caused by: java.lang.IllegalStateException: Error launching request at http://localhost:2990/jira/ArquillianServletRunner?outputMode=serializedObject&className=it.MyFirstTest&methodName=myTestMethod. No result returned
	at org.jboss.arquillian.protocol.servlet.ServletMethodExecutor.executeWithRetry(ServletMethodExecutor.java:117)
	at org.jboss.arquillian.protocol.servlet.ServletMethodExecutor.invoke(ServletMethodExecutor.java:89)
	... 76 more

Of course everything works, when I add @ExportAsService annotation to the class under test.

Is it really neccessary to make every class I want to write integration tests for an exported service ? Isn’t there some way to get around it ? Or am I misunderstanding something ?

Or is there actually some other way to write working integration tests for plugins for JIRA version 8.4.2 ? I’ve looked through official documentation and couldn’t find anything that would work for me.

It is, but you can use ExportAsDevService if you don’t want to export your services in production.
AFAIK, basically, Arquillian test classes are deployed as Jira plugins, and it needs this to interact with your plugin.

I understand. Thank you :slight_smile: