Integration testing

Kannan S November 21, 2013

Hi All,

I am following the url https://developer.atlassian.com/display/JIRADEV/Plugin+Tutorial+-+Writing+integration+tests+using+PageObjects for integration testing of my plugin.

I have assumed a few things .Please correct it if i am wrong.

1. Write a plugin with a simple submit button. This pluging will show a text "Button clicked" when someone clicks on the button.

2. I have written an integration test for this plugin following the above tutorial. ie., in the it.com.sample.tester package with the class name MyComponentWiredTest which extends TestBase. The @test method calls another class which makes use the PageElement to click on a button

package it.test.project.info.gadget;
 
import org.junit.Test;
import org.junit.runner.RunWith;
 
import com.atlassian.jira.tests.TestBase;
import com.atlassian.plugins.osgi.test.AtlassianPluginsTestRunner;
 
@RunWith(AtlassianPluginsTestRunner.class)
public class MyComponentWiredTest extends TestBase
{
                @Test
                public void testGadget(){
                                ProjectInfoDashboardGadgetIntTester tester = new ProjectInfoDashboardGadgetIntTester();
                                tester.submitDashboard();
                }

The ProjectInfoDashboardGadgetIntTester class is as follows

package it.test.project.info.gadget;
 
 
import com.atlassian.jira.pageobjects.pages.AbstractJiraPage;
import com.atlassian.pageobjects.elements.ElementBy;
import com.atlassian.pageobjects.elements.PageElement;
import com.atlassian.pageobjects.elements.query.TimedCondition;
 
public class ProjectInfoDashboardGadgetIntTester extends AbstractJiraPage{
 
                @ElementBy(id="submitButton")
                protected PageElement submitButton;
                
 
                @Override
                public String getUrl() {
                                return "/secure/Dashboard.jspa?externalSystem=com.mycompany.groupid:project-info-dashboard-gadget-plugin";
                }
 
                @Override
                public TimedCondition isAt() {
                                
                                return submitButton.timed().isVisible();
                }
                
                public void submitDashboard(){
                                submitButton.click();
                }
                
                
}

My pom.xml file has the following dependencies

<dependency>
            <groupId>com.atlassian.plugins</groupId>
            <artifactId>atlassian-plugins-osgi-testrunner</artifactId>
            <version>${plugin.testrunner.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>javax.ws.rs</groupId>
            <artifactId>jsr311-api</artifactId>
            <version>1.1.1</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>2.2.2-atlassian-1</version>
        </dependency>
        
        <dependency>
			<groupId>com.atlassian.jira</groupId>
			<artifactId>atlassian-jira-pageobjects</artifactId>
			<version>5.2.11</version>
			<scope>test</scope>
		</dependency>
		
		<dependency>
			<groupId>com.atlassian.selenium</groupId>
			<artifactId>atlassian-selenium</artifactId>
			<version>2.1-m18</version>
			<scope>test</scope>
		</dependency>
		
		<dependency>
			<groupId>com.atlassian.selenium</groupId>
			<artifactId>atlassian-pageobjects-elements</artifactId>
			<version>2.1.0-m9</version>
			<scope>test</scope>
		</dependency>
		
		 <dependency>
            <groupId>com.atlassian.jira.tests</groupId>
            <artifactId>jira-func-test-basics</artifactId>
            <version>1.9.7</version>
            <scope>test</scope>
        </dependency>

Now I am not sure how the integration test will be carried out.Upon building two jar files are generated

1. actual plugin jar file

2. actualpluginjar-"tests.jar" file

How will the integration tests be carried out with these files. Should both the files be uploaded one by one?

And if i upload the "-tests.jar" file , i could see a huge difference in size between the original plugin jar file and the "-tests.jar" file. I believe some dependency jar files are attached tot he "-tests.jar" file.

And with that i get the following exception

: Unresolved constraint in bundle com.mycompany.groupid:.test-project-info-gadget-tests [186]: Unable to resolve 186.0: missing requirement [186.0] package; (package=test.project.info.gadget)

at org.apache.felix.framework.Felix.resolveBundle(Felix.java:3409)

at org.apache.felix.framework.Felix.startBundle(Felix.java:1709)

at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:905)

at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:892)

at com.atlassian.plugin.osgi.factory.OsgiPlugin.enableInternal(OsgiPlugin.java:417)

To some extent I understand that some jar files are bundled with the plugin which are already present in the JIRA, but I am not sure about the jar files and how it can be avoided

What i assume is as soon as i upload the "-test.jar" in the admin->manage adon section, the original plugin will be tested automatically.

Is this correct?

Also i am directly working in a development environment and my system does not have and sdk server installed. In these kind of environment how do i do the integrated testing?

Suggest some ideas

2 answers

1 accepted

2 votes
Answer accepted
William Crighton _CCC_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 29, 2013

Kannan,

The environment you describe will only be a problem in that you wouldn't be able to type atlas-run and view the results locally - BUT - maybe you don't quite understand everything the SDK brings you.

If you have the SDK installed locally then you'll be able to just type 'atlas-run' (on a working plugin source dir) and the SDK will take care of spinning up an entire functional version of whatever product you are developing for - one that you'll be able to connect to via http://localhost:2990/jira - and run all your tests locally. You don't need to install JIRA (or whatever product), get a separate license for it, etc...the SDK just provides. Very cool stuff.

If machine limitations (not enuf memory, processor, etc to handle local testing) or organizational ones (i.e. management doesn't want you to test locally) or machine policy limitations (i.e. IT has blocked all ports on your machine and won't let you change it) then you're screwed...you'll need to use the remote server for testing. However, that won't limit you (any more than you're already if the previous 3 items apply) b/c you'll be able to install the two plugins created when you run atlas-package.

Now, you'll have to get shell access to the remote server so you can watch the logs, and it should be a production server as you'll be running test code on it, but you know those things.

Perhaps the examples I created for my own educational purposes would be of help:

Set of issues created to track my example's progress:

Example Code in BitBucket

From what I learned I could not get the wired test console to run any tests when I was importing jira-tests and jira-func-tests, or the testkit. Only importing testkit gave a different error (or no error, just no runnable tests) than jira-tests and jira-func-tests. So....get rid of those and create some runnable tests, or start with my example and hammer away at it until you have something working.

-wc

2 votes
William Crighton _CCC_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 24, 2013

Hey man! You have some more reading to do!

The main thing to remember is you kinda jumped in at the deep end, i.e. most difficult, part of the Atlassian testing methodology. Trying to figure it all out from there would be quite difficult.

Most all of your questions are answered across a few of the atlassian 'how to <test type>' pages such as:

1. https://developer.atlassian.com/display/DOCS/Writing+and+Running+Plugin+Tests

- go through each of these pages and all your basic 'how does this stuff work' type questions will get answered. I just read the pages, I didn't actually do the examples bit by bit...but I'm being a bit joking b/c I did the same as you and went to the most recent/advanced methodology and had to do all this back-tracking.

Quick answer about the 2 jars - you type (typically) atlas-clean; atlas-run <enter> and an instance of JIRA will be brought up by the SDK (which has to be installed) that you can access over port 2990/jira. If you got the dependencies right in your POM then you're plugins will already be installed for you. To test them click the 'Dev' thingy in the bottom left (if it's not already opened) and then click the far right icon. If things look good in your plugin config you'll see a 'Plugin Test Console' link that'll take you to where you can run the tests, make code corrections and reload the tests w/o having to do the whole s l o w integration test cycle. Thank JD for that.

-wc

William Crighton _CCC_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 24, 2013

Oh yea - there are tons of examples in bitbucket you can download to try and figure out why THERE stuff works and YOUR stuff won't...at least that's what I spent a _lot_ of time doing. Just go and browse the atlassian repositories here:

https://bitbucket.org/atlassian

and check out the tutorial related projects first, then branch out to the general plugin ones.

-wc

Kannan S November 24, 2013

Thanks William for the light thrown. I was more specific in my question. Hope you have read this part

"Also i am directly working in a development environment and my system does not have and sdk server installed. In these kind of environment how do i do the integrated testing?".

This means i will develop and plugin/gadget and then upload it to a dev server in a remote system where the jira is running. So with SDK installed in my desktop system but the local jira server not running how can i do this integration testing??? I am using the atlas-xxx only for creating a plugin skeleton and modifying it for eclipse ie.,

atlas-create-jira5-plugin

atlas-mvn eclipse:eclipse

Anyway i will go through the bitbucket .

Suggest an answer

Log in or Sign up to answer