Java Reference
In-Depth Information
Using such a library in every test means you have to include it in every micro deployment.
There is another thing you will always need: the beans.xml file. So let's create some
utility classes:
public class ArquillianWarUtils {
private static final String BEANS_XML = "beans.xml";
private static final String ASSERTJ_COORDINATE =
"org.assertj:assertj-core";
private static File[] ASSERTJ_ARTIFACT =
Maven.resolver()
.loadPomFromFile("pom.xml").resolve(ASSERTJ_COORDINATE)
.withTransitivity().asFile();
public static WebArchive getBasicWebArchive() {
return ShrinkWrap.create(WebArchive.class)
.addAsLibraries(ASSERTJ_ARTIFACT)
.addAsWebInfResource(EmptyAsset.INSTANCE,
BEANS_XML);
}
}
Also, now in each test case, you'd have just to write the following code:
@Deployment
public static WebArchive createDeployment() {
return ArquillianWarUtils.getBasicWebArchive()
.addPackage(SomePackage.class.getPackage();
}
At some point, you might want to do one more thing; instead of adding all your libraries
manually, you can import them on runtime dependencies:
Maven.resolver().loadPomFromFile("pom.xml")
.importRuntimeDependencies().resolve()
.withTransitivity().asFile();
Search WWH ::




Custom Search