Cucumber report is not getting generated for feature file in karate - karate

I have used the following java code and pom for generating cucumber reports as per the Karate documents but i am not able to get cucumber reports as expected:
In Java Class file :
package Mav_demo.RunnerFunction;
//import com.intuit.karate.junit4.Karate;
import cucumber.api.CucumberOptions;
import com.intuit.karate.cucumber.CucumberRunner;
import com.intuit.karate.cucumber.KarateStats;
//import org.junit.runner.RunWith;
import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import net.masterthought.cucumber.Configuration;
import net.masterthought.cucumber.ReportBuilder;
import org.apache.commons.io.FileUtils;
//import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;
//#RunWith(Karate.class)
//#CucumberOptions(features =
"classpath:src/test/java/Mav_demo/RunnerFunction/gapi_mulscn.feature")
#CucumberOptions(tags = "~#ignore")
public class Looping{
#Test
public void testParallel() {
String karateOutputPath = "target/surefire-reports";
KarateStats stats = CucumberRunner.parallel(getClass(), 5, karateOutputPath);
generateReport(karateOutputPath);
assertTrue("there are scenario failures", stats.getFailCount() == 0);
}
private static void generateReport(String karateOutputPath) {
Collection<File> jsonFiles = FileUtils.listFiles(new File(karateOutputPath), new String[] {"json"}, true);
List<String> jsonPaths = new ArrayList<String>(jsonFiles.size());
jsonFiles.forEach(file -> jsonPaths.add(file.getAbsolutePath()));
Configuration config = new Configuration(new File("target"), "demo");
ReportBuilder reportBuilder = new ReportBuilder(jsonPaths, config);
reportBuilder.generateReports();
}
}
In Pom.xml file
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>Mav_Demo.RunnerFunction</groupId>
<artifactId>RunnerFunction</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<maven.compiler.version>3.6.0</maven.compiler.version>
<junit.version>4.12</junit.version>
<cucumber.version>1.2.5</cucumber.version>
<selenium.version>2.53.0</selenium.version>
<maven.compiler.version>3.3</maven.compiler.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>com.intuit.karate</groupId>
<artifactId>karate-apache</artifactId>
<version>0.7.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.intuit.karate</groupId>
<artifactId>karate-junit4</artifactId>
<version>0.7.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.masterthought</groupId>
<artifactId>cucumber-reporting</artifactId>
<version>3.8.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java</artifactId>
<version>${cucumber.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-core</artifactId>
<version>${cucumber.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>${cucumber.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.masterthought</groupId>
<artifactId>cucumber-reporting</artifactId>
<version>3.7.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>${selenium.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-chrome-driver</artifactId>
<version>${selenium.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<testResources>
<testResource>
<directory>src/test/java</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</testResource>
</testResources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.10</version>
<configuration>
<includes>
<include>Mav_demo.RunnerFunction/ExamplesTest.java</include>
</includes>
<argLine>-Dfile.encoding=UTF-8</argLine>
<systemProperties>
<cucumber.options>--tags ~#ignore</cucumber.options>
</systemProperties>
</configuration>
</plugin>
</plugins>
</build>
In Feature file :
Feature: to print results
Scenario: looping the post method
Given url 'https://www.googleapis.com/geolocation/v1/geolocate'
And param key = 'AIzaSyB2jt4BQ9McqBXAe8dYcp1CwKf0oGFlWuc'
And request 'payload'
When method post
And print response
Then status 200
I am getting sure-fire reports correctly. But, not the Cucumber report. Kindly please help on this.
Thanks much...

Sorry no-one is going to read all this and figure out since this seems to be a horrible mix of Cucumber, Selenium and what not.
Please refer to this document: https://stackoverflow.com/help/mcve
Anyway, here is what I suggest. Create a fresh project using the Maven quickstart (or archetype): https://github.com/intuit/karate#quickstart
Then get the parallel reports working in that project. Refer to https://github.com/intuit/karate/tree/master/karate-demo#example-report - and note that you seem to be using a different version of the cucumber-reporting artifact.
Once you have that working and understand clearly what to do - then try to put all this into your existing (old) project. All the best.

Related

Cucumber Unsatisfiable Dependencies Exception

I am trying to use cucumber framework with selenium and appium, but while executing cucumber feature, i am getting the following exception :
cucumber.runtime.CucumberException: org.picocontainer.injectors.AbstractInjector$UnsatisfiableDependenciesException: pages.HomePage has unsatisfied dependency 'interface org.openqa.selenium.WebDriver' for constructor 'public pages.HomePage(org.openqa.selenium.WebDriver)' from org.picocontainer.DefaultPicoContainer#3f91b517:1<|
at cucumber.api.testng.TestNGCucumberRunner.runCucumber(TestNGCucumberRunner.java:69)
at cucumber.api.testng.AbstractTestNGCucumberTests.feature(AbstractTestNGCucumberTests.java:21)
Caused by: org.picocontainer.injectors.AbstractInjector$UnsatisfiableDependenciesException: pages.HomePage has unsatisfied dependency 'interface org.openqa.selenium.WebDriver' for constructor 'public pages.HomePage(org.openqa.selenium.WebDriver)' from org.picocontainer.DefaultPicoContainer#3f91b517:1<|
at org.picocontainer.injectors.ConstructorInjector.getGreediestSatisfiableConstructor(ConstructorInjector.java:191)
at org.picocontainer.injectors.ConstructorInjector.getGreediestSatisfiableConstructor(ConstructorInjector.java:110)
at org.picocontainer.injectors.ConstructorInjector.access$100(ConstructorInjector.java:51)
at org.picocontainer.injectors.ConstructorInjector$1.run(ConstructorInjector.java:331)
at org.picocontainer.injectors.AbstractInjector$ThreadLocalCyclicDependencyGuard.observe(AbstractInjector.java:270)
at org.picocontainer.injectors.ConstructorInjector.getComponentInstance(ConstructorInjector.java:364)
at org.picocontainer.injectors.AbstractInjectionFactory$LifecycleAdapter.getComponentInstance(AbstractInjectionFactory.java:56)
at org.picocontainer.behaviors.AbstractBehavior.getComponentInstance(AbstractBehavior.java:64)
at org.picocontainer.behaviors.Stored.getComponentInstance(Stored.java:91)
at org.picocontainer.DefaultPicoContainer.getInstance(DefaultPicoContainer.java:699)
at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:647)
at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:678)
at cucumber.runtime.java.picocontainer.PicoFactory.getInstance(PicoFactory.java:40)
at cucumber.runtime.java.JavaStepDefinition.execute(JavaStepDefinition.java:38)
at cucumber.runtime.StepDefinitionMatch.runStep(StepDefinitionMatch.java:37)
at cucumber.runtime.Runtime.runStep(Runtime.java:300)
at cucumber.runtime.model.StepContainer.runStep(StepContainer.java:44)
at cucumber.runtime.model.StepContainer.runSteps(StepContainer.java:39)
at cucumber.runtime.model.CucumberScenario.run(CucumberScenario.java:44)
at cucumber.runtime.model.CucumberFeature.run(CucumberFeature.java:165)
at cucumber.api.testng.TestNGCucumberRunner.runCucumber(TestNGCucumberRunner.java:63)
at cucumber.api.testng.AbstractTestNGCucumberTests.feature(AbstractTestNGCucumberTests.java:21)
at ✽.Given I open the application(Appium.feature:6)
HomePage.java
package pages;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.testng.Assert;
import cucumber.api.java.en.Given;
import cucumber.api.java.en.When;
public class HomePage extends BasePage{
public HomePage(WebDriver driver) {
super(driver);
// TODO Auto-generated constructor stub
}
By searchbutton = By.id("header-search-icon");
By wishList = By.id("header-wishlist-icon");
#Given("^I open the application$")
public void clicksearchButton() {
waitForVisibilityOf(searchbutton);
driver.findElement(searchbutton).click();
}
#When("^I tap on Accessibility$")
public void clickwishList() {
driver.get("https://www.myntra.com/");
waitForVisibilityOf(wishList);
driver.findElement(wishList).click();
}
}
Below is my POM.XML
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>TestVagrant</groupId>
<artifactId>1</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<fork>true</fork>
<executable>C:\Program Files\Java\jdk1.8.0_66\bin\javac</executable>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java</artifactId>
<version>1.2.5</version>
</dependency>
<!-- Below Dependency for TestNG -->
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-testng</artifactId>
<version>1.2.5</version>
<scope>compile</scope>
<exclusions>
<exclusion>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.10</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>1.2.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-picocontainer</artifactId>
<version>1.2.5</version>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-jvm</artifactId>
<version>1.2.5</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.0.1</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.9.8</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.appium</groupId>
<artifactId>java-client</artifactId>
<version>4.1.2</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Below is the run configuration for cucumber test:
#CucumberOptions(features={"src//test//java//feature"}
,glue={"pages"}
,plugin = {"pretty", "html:target/cucumber"}
, tags ={"#web","#Test","#appium"} ) #Test public class RunTest extends AbstractTestNGCucumberTests{
}
Try below code it should work.
Remove super(driver) inside constructor instead of that use below code
/*************************/
private BasePage basePage;
public HomePage(){
basePage = new BasePage(driver);
}
/*************************/
Let me know if you need more info

Error In Cucumber Extend report(java.lang.ClassNotFoundException: com.cucumber.listener.ExtentCucumberFormatter)

I am new in selenium.
I want to generate extend report using cucumber. But I am always getting error
"cucumber.runtime.CucumberException: Couldn't load plugin class: com.cucumber.listener.ExtentCucumberFormatter"
I tried every version Below code I have
POM XML File:
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>CucumberFramwork</groupId>
<artifactId>ExtendReport</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>ExtendReport</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.vimalselvam</groupId>
<artifactId>cucumber-extentsreport</artifactId>
<version>3.1.1</version>
</dependency>
<dependency>
<groupId>com.aventstack</groupId>
<artifactId>extentreports</artifactId>
<version>3.1.1</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>4.2.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.aventstack</groupId>
<artifactId>extentreports-cucumber4-adapter</artifactId>
<version>1.0.7</version>
</dependency>
<!-- >dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>4.2.6</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-picocontainer</artifactId>
<version>4.2.6</version>
<scope>test</scope>
</dependency -->
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java</artifactId>
<version>1.2.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-jvm</artifactId>
<version>1.2.5</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>1.2.5</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
Java Code:
package runners;
import java.io.File;
import org.junit.AfterClass;
import org.junit.runner.RunWith;
import com.vimalselvam.cucumber.listener.Reporter;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
#RunWith(Cucumber.class)
#CucumberOptions(features = "src/test/resources/functionalTests",
glue = { "stepDefinitions" }, plugin = {
"com.cucumber.listener.ExtentCucumberFormatter:target/cucumber-reports/report.html" },
monochrome = true)
public class TestRunner {
#AfterClass
public static void writeExtentReport() {
try {
Reporter.loadXMLConfig(new File("C:\\Software\\WprkSpace\\ExtendReport\\Configs\\extent-config.xml"));
}
catch (Exception e) {
e.printStackTrace();
}
//Reporter.loadXMLConfig("/ExtendReport/Configs/extent-config.xml");
}
}
Every time I am geting below error:
cucumber.runtime.CucumberException: Couldn't load plugin class:
com.cucumber.listener.ExtentCucumberFormatter
at cucumber.runtime.formatter.PluginFactory.loadClass(PluginFactory.java:180)
at cucumber.runtime.formatter.PluginFactory.pluginClass(PluginFactory.java:165)
at cucumber.runtime.formatter.PluginFactory.getPluginClass(PluginFactory.java:222)
at cucumber.runtime.formatter.PluginFactory.isStepDefinitionReporterName(PluginFactory.java:205)
at cucumber.runtime.RuntimeOptions$ParsedPluginData.addPluginName(RuntimeOptions.java:357)
at cucumber.runtime.RuntimeOptions.parse(RuntimeOptions.java:159)
at cucumber.runtime.RuntimeOptions.(RuntimeOptions.java:90)
at cucumber.runtime.RuntimeOptions.(RuntimeOptions.java:85)
at cucumber.runtime.RuntimeOptionsFactory.create(RuntimeOptionsFactory.java:23)
at cucumber.api.junit.Cucumber.(Cucumber.java:84)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:488)
at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:29)
at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:21)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:26)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createUnfilteredTest(JUnit4TestLoader.java:90)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:76)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:49)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:525)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:763)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:463)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:209)
Caused by: java.lang.ClassNotFoundException: com.cucumber.listener.ExtentCucumberFormatter
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:582)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:185)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:496)
at cucumber.runtime.formatter.PluginFactory.loadClass(PluginFactory.java:173)
... 26 more
Problem Statement Analysis -
Using vimal, avenstack and adapter dependencies all together in pom.xml which is not advisable and expected. One shall use vimal or avenstack or both together in specific use case or use adapter dependency only. Please follow below instructions.
Adding direct & transitive dependencies together from info.cukes & io.cucumber dependencies. Doing so can cause unpredictable outcome. Now let's move.
Vimal Selvam Library: Below is the required maven dependency and a sample test to demonstrate how configuration set up is done.
Maven Dependency
<dependency>
<groupId>com.vimalselvam</groupId>
<artifactId>cucumber-extentsreport</artifactId>
<version>3.1.1</version>
</dependency>
<dependency>
<groupId>com.aventstack</groupId>
<artifactId>extentreports</artifactId>
<version>4.0.9</version>
</dependency>
Please note that Java 8+ and adding the dependency of ExtentReport v3.1.1+ is mandatory.
Cucumber Runner File
#RunWith(Cucumber.class)
#CucumberOptions(
features = {"src/test/resources/features"},
glue = {"com.cucumber.stepdefinitions"},
plugin = {"com.cucumber.listener.ExtentCucumberFormatter:output/report.html"}
)
public class RunCukesTest {
#AfterClass
public static void teardown() {
Reporter.loadXMLConfig(new File("src/test/resources/extent-config.xml"));
Reporter.setSystemInfo("user", System.getProperty("user.name"));
Reporter.setSystemInfo("os", "Mac OSX");
Reporter.setTestRunnerOutput("Sample test runner output message");
}
}
The above setup will generate the report in output directory with the name of report.html.
Please remove adapter dependency from pom.xml. We shall use vimal/avenstack or extent adapter but not all together.
Extent Adapter: Beauty is, you do not need to write any code any where to generate report this way except from setting adapter in runner below.
Maven Dependency
<dependency>
<groupId>com.aventstack</groupId>
<artifactId>extentreports-cucumber4-adapter</artifactId>
<version>1.0.6</version>
</dependency>
Add the com.aventstack.extentreports.cucumber.adapter.ExtentCucumberAdapter plugin to the runner.
#RunWith(Cucumber.class)
#CucumberOptions(plugin = {"com.aventstack.extentreports.cucumber.adapter.ExtentCucumberAdapter:"})
public class RunCukesTest {
// ..
}
Report Output Directory - ../Project Directory/test-output/HtmlReport
Additional Note: In future, we would request you to use Cucumber v>=4.0.0 as you are using pretty old dependency(v1.2.5) of Cucumber.
For doing so, you can add below set of cucumber minimal dependencies.
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>4.2.6</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-picocontainer</artifactId>
<version>4.2.6</version>
<scope>test</scope>
</dependency>
Since you are using cucumber 4 version, you should be using the plugin - "com.aventstack.extentreports.cucumber.adapter.ExtentCucumberAdapter:"
cucumber-java & cucumber-junit dependency should be 4.2.6 version on your POM.
see adapter documentation- http://extentreports.com/docs/versions/4/java/cucumber4.html for more details & examples.

When I have a matching glue code eclipse throws the following error - Step 'User is already on loginpage' does not have a matching glue code

I'm unable to run my runner file in eclipse as eclipse says Step -'User is already on loginpage' does not have a matching glue code on my feature file.
Also when I close and open the feature file eclipse says- An internal error occurred during: "Scanning for step definitions".
java.lang.NullPointerException
When I run the runner file Ecipse shows the below error
You can implement missing steps with the snippets below:
#Given("^User is already on loginpage$")
public void user_is_already_on_loginpage() throws Throwable {
// Write code here that turns the phrase above into concrete actions
throw new PendingException();
} .....
I have tried specifying the path to my feature file and step definition file in so many different ways, but nothing has worked.
Feature file
Feature: Free CRM login feature
Scenario: CRM login
Given User is already on loginpage
When title of login pageis free CRM
Then user enters user name an d password
Then user clicks on login button
Then user is on homepage
Step Definition File
package stepDefinitions;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.*;
import cucumber.api.java.en.*;
import org.junit.Assert;
public class LogInStepDefinition {
WebDriver driver;
#Given("^User is already on loginpage$")
public void User_is_already_on_loginpage() {
driver=new ChromeDriver();
System.setProperty("webdriver.chrome.driver",
"C://chromedriver.exe");
driver.get("http://testing-ground.scraping.pro/login");
}
#When("^title of login pageis free CRM$")
public void title_ofloginpage_is_free_CRM() {
String ActualTitle=driver.getTitle();
Assert.assertEquals("Web Scraper Testing Ground", ActualTitle);
}
#Then("^user enters user name an d password$")
public void user_enters_user_name_and_password() {
driver.findElement(By.id("usr")).sendKeys("admin");
driver.findElement(By.id("pwd")).sendKeys("12345");
}
#Then("^user clicks on login button$")
public void user_clicks_on_login_button() {
driver.findElement(By.xpath("//*[#id='case_login']/form/input[3]")).click();
}
#Then("^user is on homepage$")
public void user_is_on_homepage() {
String pageVeri=driver.findElement(By.xpath("//*[#id='content']/div[#id='case_login']/h3[#class='success']")).getText();
Assert.assertEquals("WELCOME :)", pageVeri);;
}
}
Runner file
package Runner;
import org.junit.runner.RunWith;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
#RunWith(Cucumber.class)
#CucumberOptions(
features="src/main/java/Features/login.feature",
glue= {"/src/main/java/stepDefinitions/LogInStepDefinition.java"}
//format= {"pretty","html:test-output"}
)
public class TestRunner {
}
POM.xml
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>FreeCRMBDDFramework</groupId>
<artifactId>FreeCRMBDDFramework</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>FreeCRMBDDFramework</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java</artifactId>
<version>1.2.5</version>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>1.2.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-jvm</artifactId>
<version>1.2.5</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.59</version>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>1.2.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-jvm-deps</artifactId>
<version>1.0.6</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.masterthought</groupId>
<artifactId>cucumber-reporting</artifactId>
<version>4.5.1</version>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>gherkin</artifactId>
<version>2.12.2</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.5.3</version>
</dependency>
<!-- https://mvnrepository.com/artifact/info.cukes/cucumber-picocontainer
-->
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-picocontainer</artifactId>
<version>1.2.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-core</artifactId>
<version>1.2.5</version>
</dependency>
</dependencies>
</project>
The issue is with your glue code, remove the "/" before "src". Due to this, runner can't find your step definition file.
Changes should be: glue={"src/main/java/stepDefinitions/LogInStepDefinition.java"}
And for the issue: "Scanning for step definitions". java.lang.NullPointerException.
In the LogInStepDefinition.java file, add these individual imports:
import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;
import cucumber.api.java.en.When;
Instead of:
import cucumber.api.java.en.*;
Once changed as above, close and reopen the feature file in eclipse.

Jersey MessageBodyWriter not found for media type=text/html

I am going to display html using "Thymeleaf", but the following errors are given.
The server using is tomcat8.
My code looks like.
pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.abc.def</groupId>
<artifactId>jersey_de</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>jersey_de</name>
<build>
<finalName>jersey_de</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<inherited>true</inherited>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<!-- my setting -->
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-server</artifactId>
<version>2.21</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
<version>2.21</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.connectors</groupId>
<artifactId>jersey-apache-connector</artifactId>
<version>2.21</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-moxy</artifactId>
<version>2.21</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.ext</groupId>
<artifactId>jersey-mvc</artifactId>
<version>2.21</version>
</dependency>
<!--
<dependency>
<groupId>org.glassfish.jersey.ext</groupId>
<artifactId>jersey-mvc-jsp</artifactId>
<version>2.21</version>
</dependency>
-->
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf</artifactId>
<version>2.1.4.RELEASE</version>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
web.xml
<?xml version="1.0" encoding="UTF-8"?>
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
Jersey Web Application
org.glassfish.jersey.servlet.ServletContainer
jersey.config.server.provider.packages
com.abc.def.jersey_de
com.abc.def.jersey_de.ThymeleafViewProcessor
/WEB-INF/view/
1
Jersey Web Application
/webapi/*
javacode
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import org.glassfish.jersey.server.mvc.Viewable;
import com.abc.def.jersey_de.domain.TestPOJO;
#Path("top")
#Produces(MediaType.TEXT_PLAIN)
public class DemoCtrl {
#GET
#Produces(MediaType.TEXT_HTML)
public Viewable getIt() {
Viewable vb = new Viewable("test",new TestPOJO());
System.out.println("top end");
return vb;
}
}
ThymeleafViewProcessor
#Provider
public class ThymeleafViewProcessor implements TemplateProcessor<String> {
#Context
private HttpServletRequest request;
#Context
private HttpServletResponse response;
#Context
private ServletContext servletContext;
private final TemplateEngine templateEngine;
/**
* コンストラクタ
*/
public ThymeleafViewProcessor() {
TemplateResolver resolver = new ServletContextTemplateResolver();
resolver.setPrefix("/WEB-INF/view/");
resolver.setSuffix(".html");
resolver.setTemplateMode("HTML5");
resolver.setCacheTTLMs(3600000L);
templateEngine = new TemplateEngine();
templateEngine.setTemplateResolver(resolver);
System.out.println("ThymeleafViewProcessor end");
}
/**
* 参照させるファイル名を解決する。
*/
#Override
public String resolve(String name, MediaType mediaType) {
return name;
}
#Override
public void writeTo(String templateReference, Viewable viewable, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream out) throws IOException {
WebContext context = new WebContext(request, response, servletContext);
//HTML内でモデルオブジェクトを使用できるようにしている。
//ここはモデル名をそのまま使用できるようにした方が良い。
context.setVariable("item", viewable.getModel());
Writer writer = new OutputStreamWriter(out);
templateEngine.process(templateReference, context, writer);
writer.flush();
}
}
ApplicationSetting
#ApplicationPath("/service")
public class ApplicationSetting extends ResourceConfig {
public ApplicationSetting() {
packages(this.getClass().getPackage().getName());
register(ThymeleafViewProcessor.class);
register(MvcFeature.class);
register(LoggingFilter.class);
System.out.println("ApplicationSetting ");
}
}
It was settled.
The points that I revised are as follows.
web.xml
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>com.abc.def.jersey_de.MyApplication</param-value>
</init-param>
pom
<dependencies>
<dependency>
<groupId>javax</groupId><!-- 動きが変わらないので不要? -->
<artifactId>javaee-web-api</artifactId>
<version>7.0</version>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-servlet-api</artifactId>
<version>8.0.15</version>
</dependency>
<dependency><!-- 不要? -->
<groupId>org.glassfish.jersey</groupId>
<artifactId>jersey-bom</artifactId>
<version>${jersey.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-server</artifactId>
<version>${jersey.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet-core</artifactId>
<version>${jersey.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-moxy</artifactId>
<version>${jersey.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.ext</groupId>
<artifactId>jersey-mvc</artifactId>
<version>${jersey.version}</version>
</dependency>
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf</artifactId>
<version>2.1.4.RELEASE</version>
</dependency>
</dependencies>
<properties>
<jersey.version>2.21</jersey.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

Arquillian, glassfish & h2database

I am currently fighing quite a few issues with the creation of a database unit test environment using Arquillian. My project already works in a Glassfish 3.1.2 environment based on Seam 3, JSF and MySQL. However, when trying to set up a test environment using Arquillian, things get nasty.
My ultimate goal is an Arquillian-based unit test using a Glassfish embedded server and an embedded, in-memory h2database. I’m not picky when it comes to the embedded container, it’s just that the Arquillian JPA guide suggested that the minimal Weld container does not support JPA. That’s why I opted out towards Glassfish. Since I'm not getting even near the initialization of the persistence context, I'm not posting my persistence.xml file.
Here’s the POM I ended up with so far:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>ch.diction</groupId>
<artifactId>web-portal</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>Diction web portal</name>
<packaging>war</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jee.version>1.0.0.Final</jee.version>
<seam.version>3.1.0.Final</seam.version>
<primefaces.version>3.4</primefaces.version>
<primefaces.theme.version>1.0.8</primefaces.theme.version>
<drools.version>5.4.0.Final</drools.version>
<arquillian.version>1.0.2.Final</arquillian.version>
<arquillian.weld.version>1.0.0.CR3</arquillian.weld.version>
<junit.version>4.8.1</junit.version>
<h2.version>1.3.168</h2.version>
<weldcore.version>1.1.10-SNAPSHOT</weldcore.version>
<slf4j.version>1.6.6</slf4j.version>
</properties>
<build>
<sourceDirectory>src/main/java</sourceDirectory>
<testSourceDirectory>src/test/java</testSourceDirectory>
<outputDirectory>target/main</outputDirectory>
<testOutputDirectory>target/test</testOutputDirectory>
<resources>
<resource>
<targetPath>ch/diction/webportal/resources</targetPath>
<directory>src/main/resources</directory>
</resource>
</resources>
<testResources>
<testResource>
<targetPath>ch/diction/webportal/resources</targetPath>
<directory>src/test/resources</directory>
</testResource>
<testResource>
<targetPath>ch/diction/webportal/resources</targetPath>
<directory>src/main/resources</directory>
</testResource>
</testResources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>jboss-public-repository-group</id>
<name>JBoss Public Maven Repository Group</name>
<url>http://repository.jboss.org/nexus/content/groups/public</url>
</repository>
<repository>
<id>Java.Net</id>
<name>Java Maven Repository</name>
<url>http://download.java.net/maven/2/</url>
</repository>
<repository>
<id>prime-repo</id>
<name>PrimeFaces Maven Repository</name>
<url>http://repository.primefaces.org</url>
<layout>default</layout>
</repository>
</repositories>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jboss.seam</groupId>
<artifactId>seam-bom</artifactId>
<version>${seam.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian</groupId>
<artifactId>arquillian-bom</artifactId>
<version>${arquillian.version}</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>${primefaces.version}</version>
</dependency>
<dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>redmond</artifactId>
<version>${primefaces.theme.version}</version>
</dependency>
<dependency>
<groupId>org.jboss.seam.security</groupId>
<artifactId>seam-security</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-core</artifactId>
<version>${drools.version}</version>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-compiler</artifactId>
<version>${drools.version}</version>
<exclusions>
<exclusion>
<groupId>org.drools</groupId>
<artifactId>drools-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.jboss.seam.persistence</groupId>
<artifactId>seam-persistence</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.solder</groupId>
<artifactId>solder-impl</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.seam.transaction</groupId>
<artifactId>seam-transaction</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.seam.international</groupId>
<artifactId>seam-international-api</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.seam.international</groupId>
<artifactId>seam-international</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.jboss.seam.faces</groupId>
<artifactId>seam-faces</artifactId>
</dependency>
<!-- Test dependencies -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.junit</groupId>
<artifactId>arquillian-junit-container</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.container</groupId>
<artifactId>arquillian-glassfish-embedded-3.1</artifactId>
<version>1.0.0.CR3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.glassfish.main.extras</groupId>
<artifactId>glassfish-embedded-all</artifactId>
<version>3.1.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>${slf4j.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>${h2.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>juli</artifactId>
<version>6.0.13</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
I guess for this post, only the „Test dependencies“ are important (see comment marker), since the actual main deploy works flawlessly. Running the following unit test:
package ch.diction.webportal.test.glossary.model;
import javax.inject.Inject;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.transaction.UserTransaction;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.seam.security.SecurityInterceptor;
import org.jboss.seam.transaction.TransactionInterceptor;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import ch.diction.webportal.glossary.entity.Glossary;
import ch.diction.webportal.glossary.model.IGlossaryDataAccessObject;
import ch.diction.webportal.glossary.model.JpaGlossaryDataAccessObject;
import ch.diction.webportal.security.seam.producer.EntityManagerProducer;
#RunWith(Arquillian.class)
public class JpaGlossaryDataAccessObjectTest {
#Deployment
public static Archive<?> createDeployment() {
final Archive<?> ar = ShrinkWrap
.create(WebArchive.class, "test.war")
.addPackage(Glossary.class.getPackage())
.addClass(SecurityInterceptor.class)
.addClass(TransactionInterceptor.class)
.addClass(EntityManagerProducer.class)
.addClass(JpaGlossaryDataAccessObject.class)
.addAsWebInfResource("ch/diction/webportal/resources/security/beans.xml", "beans.xml")
.addAsResource("ch/diction/webportal/resources/persistence/persistence.xml", "META-INF/persistence.xml");
return ar;
}
#Inject
private IGlossaryDataAccessObject dao;
#PersistenceContext
private EntityManager entityManager;
#Inject
private UserTransaction userTransaction;
private void clearData() throws Exception {
userTransaction.begin();
entityManager.joinTransaction();
entityManager.createQuery("delete from Glossary").executeUpdate();
userTransaction.commit();
}
#After
public void commitTransaction() throws Exception {
userTransaction.commit();
}
private void insertData() throws Exception {
userTransaction.begin();
entityManager.joinTransaction();
// TODO: Insert records
userTransaction.commit();
entityManager.clear();
}
#Before
public void preparePersistenceTest() throws Exception {
clearData();
insertData();
startTransaction();
}
private void startTransaction() throws Exception {
userTransaction.begin();
entityManager.joinTransaction();
}
#Test
public void testCreateEmptyGlossary() {
final Glossary glossary = new Glossary("empty");
dao.store(glossary);
}
}
Now provides me with the following exception:
Caused by: java.lang.VerifyError: class com.sun.enterprise.web.WebModule overrides final method stop.()V
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:791)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2404)
at java.lang.Class.getConstructor0(Class.java:2714)
at java.lang.Class.newInstance0(Class.java:343)
at java.lang.Class.newInstance(Class.java:325)
at com.sun.hk2.component.ConstructorCreator.create(ConstructorCreator.java:65)
... 79 more
As to that, I am completely clueless. I didn’t even know these kinds of exceptions existed in java o.O ...
Thanks in advance for any suggestions here! Any help is appreciated!
Best regards
Pascal
Well, I ended up ignoring the h2database part and instead used a MySQL test database provided by a fully-fledged Glassfish 3.1.2 container. The Arquillian's embedded container proved quite a hassle and wasn't worth the trouble, when Arquillian can work with actual remote Glassfish containers instead.
This is the POM I ended up with:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>ch.diction</groupId>
<artifactId>web-portal</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>Diction web portal</name>
<packaging>war</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jee.version>1.0.0.Final</jee.version>
<seam.version>3.1.0.Final</seam.version>
<primefaces.version>3.4</primefaces.version>
<primefaces.theme.version>1.0.8</primefaces.theme.version>
<drools.version>5.4.0.Final</drools.version>
<arquillian.version>1.0.2.Final</arquillian.version>
<arquillian.persistence.version>1.0.0.Alpha5</arquillian.persistence.version>
<junit.version>4.8.1</junit.version>
<slf4j.version>1.6.6</slf4j.version>
</properties>
<build>
<sourceDirectory>src/main/java</sourceDirectory>
<testSourceDirectory>src/test/java</testSourceDirectory>
<outputDirectory>target/main</outputDirectory>
<testOutputDirectory>target/test</testOutputDirectory>
<resources>
<resource>
<targetPath>ch/diction/webportal/resources</targetPath>
<directory>src/main/resources</directory>
</resource>
</resources>
<testResources>
<testResource>
<targetPath>ch/diction/webportal/resources</targetPath>
<directory>src/test/resources</directory>
</testResource>
<testResource>
<directory>src/test/resources/container</directory>
</testResource>
<testResource>
<targetPath>ch/diction/webportal/resources</targetPath>
<directory>src/main/resources</directory>
</testResource>
</testResources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>jboss-public-repository-group</id>
<name>JBoss Public Maven Repository Group</name>
<url>http://repository.jboss.org/nexus/content/groups/public</url>
</repository>
<repository>
<id>Java.Net</id>
<name>Java Maven Repository</name>
<url>http://download.java.net/maven/2/</url>
</repository>
<repository>
<id>prime-repo</id>
<name>PrimeFaces Maven Repository</name>
<url>http://repository.primefaces.org</url>
<layout>default</layout>
</repository>
</repositories>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jboss.seam</groupId>
<artifactId>seam-bom</artifactId>
<version>${seam.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian</groupId>
<artifactId>arquillian-bom</artifactId>
<version>${arquillian.version}</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>${primefaces.version}</version>
</dependency>
<dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>redmond</artifactId>
<version>${primefaces.theme.version}</version>
</dependency>
<dependency>
<groupId>org.jboss.seam.security</groupId>
<artifactId>seam-security</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-core</artifactId>
<version>${drools.version}</version>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-compiler</artifactId>
<version>${drools.version}</version>
<exclusions>
<exclusion>
<groupId>org.drools</groupId>
<artifactId>drools-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.jboss.seam.persistence</groupId>
<artifactId>seam-persistence</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.solder</groupId>
<artifactId>solder-impl</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.seam.transaction</groupId>
<artifactId>seam-transaction</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.seam.international</groupId>
<artifactId>seam-international-api</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.seam.international</groupId>
<artifactId>seam-international</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.jboss.seam.faces</groupId>
<artifactId>seam-faces</artifactId>
</dependency>
<!-- Test dependencies -->
<dependency>
<groupId>org.jboss.spec</groupId>
<artifactId>jboss-javaee-6.0</artifactId>
<version>${jee.version}</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.junit</groupId>
<artifactId>arquillian-junit-container</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.container</groupId>
<artifactId>arquillian-glassfish-remote-3.1</artifactId>
<version>1.0.0.CR3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.extension</groupId>
<artifactId>arquillian-persistence-impl</artifactId>
<version>${arquillian.persistence.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.shrinkwrap.resolver</groupId>
<artifactId>shrinkwrap-resolver-impl-maven</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
And my test-persistence.xml:
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0">
<persistence-unit name="web-portal-test" transaction-type="JTA">
<jta-data-source>jdbc/web-portal-test</jta-data-source>
<properties>
<property name="eclipselink.logging.level" value="FINE" />
</properties>
</persistence-unit>
</persistence>
The lesson I get from this is that Arquillian is too bleeding edge to provoke unnecessary configuration issues. From now on, I'll always start out with a full remote container.