Git Product home page Git Product logo

arquillian-suite-extension's Introduction

The Arquillian Suite Extension

Build Status Coverage Status

The Extension will force all Classes in a Module into a TestSuite running from the same DeploymentScenario.

Class marked with @ArquillianSuiteDeployment will be used as a 'template' for all other TestClass scenarios.

Deploy will occur only once on first test witch require Arquillian.

So far tested on:

  • Jboss 7.1, Jboss 7.2
  • EAP 6.1, EAP 6.2
  • Wildfly 8.0.0
  • Glassfish 3.2.2
  • Should work on other servers too

From version 1.1.0 working with domain mode (see extended usage).

Basic Usage

Add module to test classpath.

<dependency>
    <groupId>org.eu.ingwar.tools</groupId>
    <artifactId>arquillian-suite-extension</artifactId>
    <version>1.1.1</version>
    <scope>test</scope>
</dependency>

Mark one of your test classes with annotation @ArquillianSuiteDeployment along with usual @Deployment annotation on method.

@ArquillianSuiteDeployment
public class Deployments {

    @Deployment
    public static WebArchive deploy() {
        return ShrinkWrap.create(WebArchive.class)
            .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml")
            .addPackage(Deployments.class.getPackage());
    }
}

Run test either from IDE or maven.

Make sure you use servlet protocol!

To do that add following to arquillian.xml:

<defaultProtocol type="Servlet 3.0"/>

Or mark your deployments with annotation @OverProtocol("Servlet 3.0")

Extended usage

Getting SNAPSHOT versions of the plugin

If you really want to use snapshots, here's the repository they are deployed to.

<pluginRepositories>
    <pluginRepository>
        <id>sonatype-snapshots</id>
        <name>Sonatype Snapshots</name>
        <url>https://oss.sonatype.org/content/repositories/snapshots/</url>
    </pluginRepository>
</pluginRepositories>

Generic builder

That project contains generic builder with should work for most simple J2EE cases. You dont need to define deployment yourself but you can use generic builder to do work for you.

Basic usage for EJB module looks like.

    @Deployment
    public static EnterpriseArchive generateAutogeneratedDeployment() {
      EnterpriseArchive ear = EarGenericBuilder.getModuleDeployment(ModuleType.EJB);
        return ear;
    }

Multi deployment

As with normal arquillian you can define more than one deployment and then force tests to run on one of them. You can run them in order you like adding order attribute to @Dployment annotation.

@ArquillianSuiteDeployment
public class Deployments {

    @Deployment(name = "normal", order = 2)
    public static Archive<?> generateDefaultDeployment() {
        return ShrinkWrap.create(WebArchive.class, "normal.war")
            .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml")
            .addClass(Deployments.class)
            .addClass(InjectedObject.class)
            .addPackage(Extension1Test.class.getPackage());
    }

    @Deployment(name = "extra", order = 1)
    public static Archive<?> generateExtraDeployment() {
        Archive<?> ejb = ShrinkWrap.create(WebArchive.class, "extra_ejb.war")
            .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml")
            .addClass(Deployments.class)
            .addClass(InjectedObject.class)
            .addPackage(ExtensionExtra1Test.class.getPackage());
        return ejb;
    }
}

Then at test methods you need to add annotation @OperateOnDeployment("name")

@Test
@OperateOnDeployment("normal")
public void testNormal() {
    // Test on normal deployment
}

@Test
@OperateOnDeployment("extra")
public void testExtra() {
    // Test on extra deployment
}

Domain deployment

To use domain to test classes you need to do few extra steps.

  • Mark your deployment with @TargetsContainer("container-name")

  • Change arquillian container to domain one.

  • And add group for container in arquillian.xml

All of that + extra switching betweeen standalone/domain is done in that project itself.

Easiest way to move to suite:

  • Move all deployments to one class and make all your tests extend that class..
  • If you have more than one deployment name them and add everywhere in your tests @OperateOnDeployment
  • Check if everything is working
  • Dont go further unless your tests are not working at that moment (probably will work much slower then normally)
  • Add arquillian-suite as dependency
  • Check if its working (should work slow as before)
  • Add @ArquillianSuiteDeployment annotation on your deployment class
  • Now check if your deployments deploy only once.

That way if you will ever wonder if suite is failing your build only thing you will need to do is comment out @ArquillianSuiteDeployment and checks if its working then. If not its not suite related problem.

Extra info

Credits

Most work was done by Aslak Knutsen

I just mixed things up..

Continuous integration

Travis CI builds the plugin with Oracle and Open JDK 7. All successfully built snapshots are deployed to Sonatype OSS repository. Jacoco is used to gather coverage metrics and the report is submitted to Coveralls.

License

The project is licensed under the Apache License, Version 2.0.

arquillian-suite-extension's People

Contributors

ingwarsw avatar aslakknutsen avatar bitdeli-chef avatar tisoft avatar mdanter avatar dejewi avatar

Watchers

Ramit Bedi avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.