Cargo

Create a test runner that allows for jwebunit / httpunit functional tests to utilize cargo

Details

  • Type: New Feature New Feature
  • Status: Open Open
  • Priority: Major Major
  • Resolution: Unresolved
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: Core, Generic
  • Labels:
    None
  • Number of attachments :
    1

Description

Currently there is no neat way to use cargo in your functional tests. The current examples included with cargo start and stop the server on a per-test basis, whereas for most functional test runs, you want to start the server, run all the tests, and then stop the server.

Other complications include that you want to pass more information back to your tests than just the url to test against. You may also want to pass information about what version of your software is deployed etc.

Another goal is to have multi-threaded tests, so that on large SMP machines, you can run tests against multiple application servers at the same time.

Activity

Hide
Scott Farquhar added a comment -

Attached a first pass of a test runner using Cargo (18Mar06).

Examples of how it is used. Note the JIRA CallbackFactory is used to pass specific properties to the tests (such as 'are we testing JIRA professional, or JIRA Enterprise)

public class AcceptanceTestHarness
{
    public static Test suite() throws IOException
        {
            Collection tests = new ArrayList();
            tests.add(TestBasic.class);
        // add more tests here.            
            return TestRunner.suite(tests, getProperties(), 
                      new JIRACallbackFactory("/atlassian-jira"), 
                      new File("/Users/sfarquhar/src/atlassian/jira-jetty-fix/target/atlassian-jira"), true, false);
        }

        private static Properties getProperties() throws IOException {
            Properties containerProperties = new Properties();
            containerProperties.load(new FileInputStream("/Users/sfarquhar/src/atlassian/cargo-test-runner/containers.properties"));
            return containerProperties;
        }

        private static class JIRACallbackFactory implements TestSetupCallbackFactory
        {
            private final String urlPrefix;

            public JIRACallbackFactory(String urlPrefix)
            {
                this.urlPrefix = urlPrefix;
            }

            public TestSetupCallback getTestSetupCallback(final String containerId, final Properties properties)
            {
                return new TestSetupCallback()
                {
                    public void setupTest(Test test)
                    {
                        ServerInformation serverInformation = ServerInformationFactory.getServerInformation(containerId, properties);
                        JIRAEnvironmentData environmentData = 
                                 new JIRAEnvironmentData(serverInformation.getHttpPort(), urlPrefix, containerId, properties);
                        if (test instanceof JIRAWebSetup)
                            ((JIRAWebSetup)test).setJIRAEnvironmentData(environmentData);

                    }                };
            }
        }
}
Show
Scott Farquhar added a comment - Attached a first pass of a test runner using Cargo (18Mar06). Examples of how it is used. Note the JIRA CallbackFactory is used to pass specific properties to the tests (such as 'are we testing JIRA professional, or JIRA Enterprise)
public class AcceptanceTestHarness
{
    public static Test suite() throws IOException
        {
            Collection tests = new ArrayList();
            tests.add(TestBasic.class);
        // add more tests here.            
            return TestRunner.suite(tests, getProperties(), 
                      new JIRACallbackFactory("/atlassian-jira"), 
                      new File("/Users/sfarquhar/src/atlassian/jira-jetty-fix/target/atlassian-jira"), true, false);
        }

        private static Properties getProperties() throws IOException {
            Properties containerProperties = new Properties();
            containerProperties.load(new FileInputStream("/Users/sfarquhar/src/atlassian/cargo-test-runner/containers.properties"));
            return containerProperties;
        }

        private static class JIRACallbackFactory implements TestSetupCallbackFactory
        {
            private final String urlPrefix;

            public JIRACallbackFactory(String urlPrefix)
            {
                this.urlPrefix = urlPrefix;
            }

            public TestSetupCallback getTestSetupCallback(final String containerId, final Properties properties)
            {
                return new TestSetupCallback()
                {
                    public void setupTest(Test test)
                    {
                        ServerInformation serverInformation = ServerInformationFactory.getServerInformation(containerId, properties);
                        JIRAEnvironmentData environmentData = 
                                 new JIRAEnvironmentData(serverInformation.getHttpPort(), urlPrefix, containerId, properties);
                        if (test instanceof JIRAWebSetup)
                            ((JIRAWebSetup)test).setJIRAEnvironmentData(environmentData);

                    }                };
            }
        }
}
Hide
Scott Farquhar added a comment -

This is also being checked into subversion here:

http://svn.atlassian.com/svn/public/contrib/cargo-test-runner/

Until I get commit access to Cargo.

Show
Scott Farquhar added a comment - This is also being checked into subversion here: http://svn.atlassian.com/svn/public/contrib/cargo-test-runner/ Until I get commit access to Cargo.
Hide
Vincent Massol added a comment -
Show
Vincent Massol added a comment - Added code to the Cargo contrib area in https://svn.codehaus.org/cargo/cargo/trunk/contrib/testrunner/

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated: