Tests in plugin console fail with java.lang.Exception: No runnable methods

Tim Gesekus November 7, 2013

I have a proplem to run my integration tests in the plugin console. The tests are found but when run fail with:

java.lang.Exception: No runnable methods

The test source:

import org.apache.wink.client.ClientConfig;
import org.apache.wink.client.Resource;
import org.apache.wink.client.RestClient;
import org.junit.BeforeClass;
import org.junit.Test;

import com.atlassian.jira.functest.framework.FuncTestCase;
import com.atlassian.jira.testkit.client.Backdoor;
import com.atlassian.jira.testkit.client.util.TestKitLocalEnvironmentData;
import com.atlassian.jira.testkit.client.util.TimeBombLicence;

import de.dfs.versionstorage.rest.VersionResource;

public class VersionRestRessourceTest extends FuncTestCase
{
  @BeforeClass
  public void boo()
  {

  }


  public VersionRestRessourceTest()
  {
    // TODO Auto-generated constructor stub
  }


  @Override
  protected void setUpTest()
  {
    Backdoor testKit = new Backdoor(new TestKitLocalEnvironmentData());
    testKit.restoreBlankInstance(TimeBombLicence.LICENCE_FOR_TESTING);
    testKit.usersAndGroups().addUser("test-user");
    testKit.websudo().disable();
    testKit.subtask().enable();
    super.setUpTest();
  }


  @Test
  public void testGetAll()
  {
    String baseUrl = System.getProperty("baseurl");
    System.err.println("BASE id" + baseUrl);
    String resourceUrl = baseUrl + "/rest/versionStorage/1.0/version";

    ClientConfig config = new ClientConfig();
    RestClient client = new RestClient(config);
    Resource resource = client.resource(resourceUrl);
    resource.post(new VersionResource("DFSNEW", "Version1"));

    // String message = resource.get(String.class);

    // assertEquals("wrong message","test1",message);
  }

}

Anyone and idea?

Tim

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

6 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

Alright man, here is my answer:

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

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.
December 3, 2013

After way more struggle than should have been required I've managed to figure out why including the testkit-client dependency in my POM made my tests un-runnable.

The testkit-client has a dependency on junit-deps, which comes with it's own junit.TestClass (@Test annotation). Sooo...osgi classloader rules are such that every plugin has it's own classloader and identical classes loaded by different classloaders (which happens with dependencies) can never be equal. So what was happening in my case is junit.TestClass was being loaded by junit's classloader and put into an annotations hash to use when searching for annotated tests. Well, during that process junit-deps junit.TestClass was loaded and put in the same hash - was interesting to follow in the debugger - and used to search for @Test annotations which it could never equal.

Simple solution was to add the following to my POM file:

<plugins>
            <plugin>
                <groupId>com.atlassian.maven.plugins</groupId>
                <artifactId>maven-jira-plugin</artifactId>
                <stuff/>
                <configuration>
                    <products>
                        <more stuff/>
                    </products>
                    <productVersion>${jira.version}</productVersion>
                    <productDataVersion>${jira.version}</productDataVersion>

                    <more config stuff/>

                    <testBundleExcludes>
                        <testBundleExclude>
                            <groupId>atlassian</groupId>
                        </testBundleExclude>
                        <testBundleExclude>
                            <groupId>junit</groupId>
                            <artifactId>junit-dep</artifactId>
                        </testBundleExclude>
                    </testBundleExcludes>

4 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 25, 2013

wow....this fu***ng website does it to me again...type in a nice message and then get the 'login and add answer' only to see all my text DISAPPEAR after logging in.

Sadly, I have no joy to share with you. I cannot make it work either. Same problem. I've been using a wide variety of sites for assistance - one of the best examples I've found is this atlassian bitbucket project written by JD:

03:25:49:--> git remote -v
origin git@bitbucket.org:atlassian/jira-workflow-sharing-plugin-parent.git (fetch)
origin git@bitbucket.org:atlassian/jira-workflow-sharing-plugin-parent.git (push)

JD's the guy who wrote the testkit package and could probably answer this in like 30 seconds.

One thing I've seen most of the wired example tests do is add this annotation before the class declaration:

@RunWith(AtlassianPluginsTestRunner.class)
public class LastCommentPluginIsEnabledTest extends FuncTestCase
{

However, again, this has brought me no joy.

I've read another few lines that hinted at a solution on this page in Step 2, talking about changes to the test's atlassian-plugin.xml file. But I've made those and still no joy. (primarily just making sure you have a separate a-p.xml file for you test side plugin and that it's importing all of the classes your tests need, with dependencies listed in the project pom).

I'll reach out to JD - I'm about out of ideas. If you fall into the light please take a few minutes to show me the way as well.

Cheers,

-wc

Tim Gesekus December 8, 2013

Worked for me. Thanks

TAGS
AUG Leaders

Atlassian Community Events