- Create a Test class using Arquillian
import java.io.InputStream;
import java.util.concurrent.TimeUnit;
import junit.framework.Assert;
import org.apache.commons.io.FileUtils;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.RunAsClient;
import org.jboss.arquillian.drone.api.annotation.Drone;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.junit.InSequence;
import org.jboss.osgi.metadata.OSGiManifestBuilder;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.Asset;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.openqa.selenium.Alert;
import org.openqa.selenium.By;
import org.openqa.selenium.NoAlertPresentException;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.osgi.framework.Bundle;
@RunAsClient
@RunWith(Arquillian.class)
public class SampleTest {
@Drone
protected WebDriver driver;
protected StringBuffer verificationErrors = new StringBuffer();
@Deployment(testable = false)
public static JavaArchive createdeployment() {
final JavaArchive archive = ShrinkWrap.create(JavaArchive.class, "test.jar");
archive.setManifest(new Asset() {
@Override
public InputStream openStream()
{
OSGiManifestBuilder builder = OSGiManifestBuilder.newInstance();
builder.addBundleSymbolicName(archive.getName());
builder.addBundleManifestVersion(2);
builder.addImportPackages(Bundle.class);
return builder.openStream();
}
});
return archive;
}
@Before
public void setUp() throws Exception {
}
@Test
@InSequence(1)
public void firstTest()
{
System.out.println("firstTest()");
}
@Test
@InSequence(2)
public void secondTest()
{
System.out.println("secondTest()");
}
@After
public void tearDown() throws Exception {
String verificationErrorString = verificationErrors.toString();
verificationErrors = new StringBuffer();
if (!"".equals(verificationErrorString))
{
Assert.fail(verificationErrorString);
}
}
}
- Launch it in OSGi using with the plugin:
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-surefire-plugin</artifactId>