Disclaimer: I've gone through so many different sources before I came here to ask this question. I've referenced the GitHub project for geb with maven, book of geb, numerous YouTube tutorials, etc. Nothing has worked.
I'm simply trying to just get a project up and running that does a very simple automated search engine test, just so I can play with the tools.
Here is my 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>nope</groupId>
<artifactId>nope</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>testing this</name>
<description>testing this</description>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<!-- https://mvnrepository.com/artifact/junit/junit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.spockframework/spock-core -->
<dependency>
<groupId>org.spockframework</groupId>
<artifactId>spock-core</artifactId>
<version>1.1-groovy-2.4</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.codehaus.groovy/groovy-all -->
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>2.4.13</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.gebish/geb-spock -->
<dependency>
<groupId>org.gebish</groupId>
<artifactId>geb-spock</artifactId>
<version>2.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-firefox-driver -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-firefox-driver</artifactId>
<version>3.9.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-chrome-driver -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-chrome-driver</artifactId>
<version>3.9.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-support -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-support</artifactId>
<version>3.9.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-server -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server</artifactId>
<version>3.9.1</version>
</dependency>
</dependencies>
</project>
Main Groovy test class:
package com.na.tests
import spock.lang.Specification
import geb.*
class MyBaseTests extends Specification {
def "search 'Groovy Browser Automation' in duckduckgo"() {
given: "we are on the duckduckgo search-engine"
go "http://duckduckgo.com"
when: "we search for 'Groovy Browser Automation'"
$("#search_form_homepage").q = "Groovy Browser Automation"
$("#search_button_homepage").click()
then: "the first result is the geb website"
assert $("#links").find(".links_main a", 0).attr("href") == "http://www.gebish.org/"
}
}
This is the exception I get in the test. I've run a really simple assert Hello World test that has passed, I eliminated that for the sake of clarity.:
groovy.lang.MissingMethodException: No signature of method:
com.na.tests.MyBaseTests.go() is applicable for argument types:
(java.lang.String) values: [http://duckduckgo.com] Possible solutions:
is(java.lang.Object), Mock(), Spy(), any(), grep(),
Mock(groovy.lang.Closure) at com.na.tests.MyBaseTests.search 'Groovy
Browser Automation' in duckduckgo(MyBaseTests.groovy:22)
Edit
It's worth noting that in my IDE (Eclipse), it seems some of the keywords are either not recognized or are not legit (ie: go "http://duckduckgo.com"). Makes me feel like I haven't configured something.
You need to extend geb.spock.GebSpec and not Specification if you want to use geb. See also gebish.org/manual/current/#spock-junit-testng
On GitHub I have a set of three Maven projects which together set up Spock, Geb and multi-browser testing via Maven configuration. You can switch the browser used easily among HtmlUnit, PhantomJS, Chrome, Firefox, IE, Edge, Opera. It comes with a small series of sample tests and a prepared Geb configuration:
Maven BoM
Test resources
Sample tests
Just clone and build them all mvn clean install in the order listed here and run the tests from the third. You can, of course, put everything into one module, but I think it makes more sense to keep version management and dependency management separate from the actual application so as to be able to re-use those test dependencies, as is good Maven practice.
Update:
Then just add your test to the sample project and run it. I renamed the class so as to end with *Test instead of *Tests because this is how Maven by default finds unit tests via Surefire. If you rather like it to run as an integration test because it opens a browser and basically is slow, rename it to *IT.
I also fixed the base class as Leonard suggested correctly and changed the explicit to an implicit assert.
package com.na.tests
import geb.spock.GebSpec
class MyBaseTest extends GebSpec {
def "search 'Groovy Browser Automation' in duckduckgo"() {
given: "we are on the duckduckgo search-engine"
go "http://duckduckgo.com"
when: "we search for 'Groovy Browser Automation'"
$("#search_form_homepage").q = "Groovy Browser Automation"
$("#search_button_homepage").click()
then: "the first result (excluding ads) is the geb website"
$("#links").$(".links_main a", 0).attr("href") == "http://www.gebish.org/"
}
}
Related
I have unit tests in my springboot project in addition to the default application test that comes with the project bundle when I create the project from start.spring.io. When I run mvn test from command line, I see that only the default application tests are run but not the unit tests that I have written. However, I can run these tests from IntelliJ. I am using maven version 3.6.2 and maven surefire plugin version 2.22.2. Can someone let me know what I am missing here? Thanks.
Here's my test class:
#RunWith(SpringRunner.class)
#SpringBootTest
public class BranchServiceUnitTest {
#Autowired
private BranchService branchService;
#MockBean
private BranchRepository branchRepository;
#Test
public void testAddNewBranch() {
Branch testBranch = new Branch();
testBranch.setBranchName("TestBranch");
testBranch.setCity("TestCity");
testBranch.setContactNumber("TestContactNumber");
testBranch.setEmailId("TestEmailId");
Mockito.when(branchRepository.save(testBranch)).thenReturn(testBranch);
Branch addedBranch = branchService.addBranch(testBranch);
assertThat(addedBranch.getCity()).isEqualTo("TestCity");
}
#Test
public void findBranchById() {
Branch testBranch = new Branch();
testBranch.setId(1);
testBranch.setBranchName("TestBranch");
testBranch.setCity("TestCity");
testBranch.setContactNumber("TestContactNumber");
testBranch.setEmailId("TestEmailId");
Mockito.when(branchRepository.findById(testBranch.getId())).thenReturn(java.util.Optional.of(testBranch));
Branch foundBranch = branchService.getBranchById(1);
assertThat(foundBranch.getId()).isEqualTo(1);
}
#Test
public void testGetAllBranches() {
Branch testBranch1 = new Branch();
testBranch1.setId(1);
testBranch1.setBranchName("TestBranch");
testBranch1.setCity("TestCity");
testBranch1.setContactNumber("TestContactNumber");
testBranch1.setEmailId("TestEmailId");
Branch testBranch2 = new Branch();
testBranch2.setId(2);
testBranch2.setBranchName("TestBranch");
testBranch2.setCity("TestCity");
testBranch2.setContactNumber("TestContactNumber");
testBranch2.setEmailId("TestEmailId");
List<Branch> branches = Arrays.asList(testBranch1,testBranch2);
Mockito.when(branchRepository.findAll()).thenReturn(branches);
assertThat(branches.size()).isEqualTo(2);
assertThat(branches.get(0).getId()).isEqualTo(1);
}
}
Following is my pom file:
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.6.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.rkasibha</groupId>
<artifactId>rentabook</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>rentabook</name>
<description>Rent a book service</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.modelmapper</groupId>
<artifactId>modelmapper</artifactId>
<version>2.3.6</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
I think its a weird mix of JUnit 4 and Junit 5 that causes the issue:
Spring boot 2.2.6 (I've used start.spring.io to generate a sample application) uses junit 5.
On the other hand, your test is written with #RunWith which means that it uses junit 4 under the hood.
The dependency:
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
also seems suspicious - the spring-boot-starter-test already contains all the required dependencies on JUnit 5, so you don't need this one.
Now in terms of resolution, check out the default test that comes with this sample application (the one you've described in the question). The chances are that it uses JUnit 5 by itself, so you better migrate your test to JUnit 5 and rerun.
This looks spurious.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<includes>
<include>**/*Test*.java</include>
</includes>
</configuration>
</plugin>
What do you hope to gain from using <include>**/*Test*.java</include>? I'm pretty certain the trailing * does not mean zero-or-more characters. It's 1 or more. Documentation
Are there specific classes in your test directory that you want to exclude? If not, I would remove the whole plugin. Surefire is already declared in Maven's implicit parent POM, with sensible defaults that will cover all of your tests. Declaring it yourself is both needlessly verbose and has actively broken something which works out of the box.
If your tests run successfully when ran alone, But not picked up during the
mvn test
Chances are that you might be using an Older Junit package in your tests. Usually the above weird scenario happens when there's a mix up in the Junit version.
If Junit5 is being used, please ensure that the package in imports is
import org.junit.jupiter.api
I'm trying to upgrade an application to Java 11.0.2, from Java 8. So those are my very first steps with Jigsaw modules!
My application uses Guice, and the Assistedinject, and Throwingproviders extensions.
Here's my current module-info.java:
`
module com.example.mymodule {
requires com.google.guice;
requires com.google.guice.extensions.assistedinject;
requires com.google.guice.extensions.throwingproviders;
//...
}
`
The application is based on Maven and when I run mvn package I get no error. But In Eclipse (2018-12), I have this error "`The package com.google.inject is accessible from more than one module":
I tried commenting each of the required module in module-info.java but I clearly need the three of them.
Is there something I can do to remove this error? Or is this an Eclipse bug?
Here's 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>com.example</groupId>
<artifactId>example</artifactId>
<version>1.0.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.7</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
<version>4.5.7</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.8.1</version>
</dependency>
<dependency>
<groupId>commons-validator</groupId>
<artifactId>commons-validator</artifactId>
<version>1.6</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-text</artifactId>
<version>1.6</version>
</dependency>
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.11.3</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.26</version>
</dependency>
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
<version>4.2.2</version>
</dependency>
<dependency>
<groupId>com.google.inject.extensions</groupId>
<artifactId>guice-throwingproviders</artifactId>
<version>4.2.2</version>
</dependency>
<dependency>
<groupId>com.google.inject.extensions</groupId>
<artifactId>guice-assistedinject</artifactId>
<version>4.2.2</version>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
</plugins>
</build>
</project>
Here is a minimal project to reproduce my error.
And here's a video of the issue (to be watched in 1080P for clarity!).
Eclipse uses its own compiler which is even stricter than javac in following the specs. You are requiring different Modules/Jars in your module-info which are all using the package com.google.inject. This is some kind of a split package situation which is not allowed in the JPMS spec. AFAIK javac only yields an error if there are actual classes in the same packages of different moduls, but the eclipse compiler is even more picky here.
There are some solutions out there for solving split package problems. If you don't find a newer version of the libs where the problem is solved (which unfortunately is not very likely for most dependencies today) you could f.e. merge the modules into one custom modules, but this is not a perfect solution of course.
For more background information on the issue see also
Eclipse can't find XML related classes after switching build path to JDK 10 and https://bugs.openjdk.java.net/browse/JDK-8215739
I can reproduce the error on my machine (same Eclipse version, OpenJDK 11), works fine on Apache NetBeans IDE 10.0.
Seems to be a bug in Eclipse, you should file it here. You already have a minimal project that reproduces the error, that helps a lot.
Your test project already works in RC2 of 4.11 (which will be released on March 20, 2019)
You can download the release candidate at https://download.eclipse.org/eclipse/downloads/drops4/S-4.11RC2-201903070500/
Better way to deal with this kind of problem by just go to dependencies hierarchy in pom.xml, where you can find duplicate jar, sometimes it could be difficult to find duplicate jar as jar itself have pom dependencies and "Dependencies hierarchy" will help you to deal with maven problem
`
I am currently writing a Lucene Tokenizer and I want to test my class. For the test, I got inspiration from the Lucene test class TestStandardFactories which is a child class of the testing class BaseTokenStreamTestCase. Accordingly my test class is also a child class of BaseTokenStreamTestCase.
I apply Maven and hence my pom.xml looks like this:
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>de.institute.taggedtexttokenizer</groupId>
<artifactId>tagged-text-tokenizer</artifactId>
<version>0.2</version>
<properties>
<lucene-version>7.2.0</lucene-version>
</properties>
<dependencies>
<!-- https://mvnrepository.com/artifact/commons-lang/commons-lang -->
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.lucene/lucene-test-framework -->
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-test-framework</artifactId>
<version>${lucene-version}</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.lucene/lucene-core -->
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-core</artifactId>
<version>${lucene-version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.lucene/lucene-analyzers-common -->
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-analyzers-common</artifactId>
<version>${lucene-version}</version>
</dependency>
</dependencies>
</project>
I expected the BaseTokenStreamTestCase to be in the lucene-test-framework and hence my test to run properly. However, the compiler complains that it cannot find the class BaseTokenStreamTestCase. A quick look in the lucene-test-framework assured me that this class is not contained in there.
Which Maven dependency do I need to include to have access to this class?
I double checked and lucene-test-framework artifact contains needed class: org.apache.lucene.analysis.BaseTokenStreamTestCase.
One of the possible reasons, why compiler complaints about this class is, because you are using <scope>test</scope>, which means, that the dependency is not required for normal use of the application, and is only available for the test compilation and execution phases.
For example, you may put this test into src/main/java place, so it's test dependency couldn't pick it up.
I'm spinning my wheels trying to run tests in intellij. I'm using the basic framework of a cucumber skeleton project as such.
I have also updated my POM file as such:
<?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>MaritProject</groupId>
<artifactId>MaritProject</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
<!-- https://mvnrepository.com/artifact/info.cukes/cucumber-java -->
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java</artifactId>
<version>1.2.5</version>
</dependency>
</dependencies>
</project>
Environment: I am on jdk 1.8 and the JDK has been selected in settings. I've also gone to settings, plug ins and installed the Cucumber for Java plug in. I'm on windows 10.
Requirement: I want to run a basic test of the feature file, which without having anything yet in my runner class, should tell me that zero tests are working and give me the basic output of a step definition file to cut and paste and start fleshing out details in. Then, I want to write and execute the runner file.
Problem: But when I run this feature file, either nothing happens or when I fill out some of the edit configuration, I get "Error running: 'Unnamed: No module defined'. I am following some video tutorials where the run output window looks much different than what I had, so I upgraded my IntellJ to the latest version, 2017.3.5
I have checked the markings on my directory and it looks like Java is correctly marked as Sources under main, java is marked as test Sources under src/test and resources are marked as resources under main and resources root under test. This probably should be all I need, as the video said to do even less than this. When I run mvn clean test in the directory of my project, I get BUILD SUCCESS back.
But, since I upgraded IntelliJ in attempt to correct a different issue, now I cannot run any feature or class file. It wants me to edit my configurations first. These configurations include a main class, glue, feature or folder path, VM options, program arguments, working directory, environment variables and classpath of module. This window was not there previously when I tried to run. I don't know what to put in any of these input boxes and google results have so far been unhelpful. How do I tell what my main class is or what the glue is? Glue looks like a required field, but I don't know what path corresponds to the glue. I can guess that my working directory is where the files are stored. I have my java and maven home environment variables saved on my machine, but do I also need them in intellij?
I have had some troubles getting this stuff to work. For this configuration works:
<properties>
<java.version>1.8</java.version>
<junit.version>4.12</junit.version>
<cucumber.version>1.2.5</cucumber.version>
<maven.compiler.version>3.3</maven.compiler.version>
</properties>
<dependencies>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java8</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>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
Note that I have the versions specified a inside , they could also be provided inline.
Other than that you have to specify glue. This is the directory where your stepDefinition files are. Your glue and features and so on can be specified in a testrunnerclass or something like that. However note that this class HAS TO HAVE "Test" in the name. Something like TestRunner or CukesRunTest will do. RunnerClass will not be recognized.
Please remove
<!-- https://mvnrepository.com/artifact/info.cukes/cucumber-java -->
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java</artifactId>
<version>1.2.5</version>
</dependency>
as you have two versions of cucumber currently in your pom.xml
I am trying to implement the Allure Reporting for my Selenium framework. It does not use any test framework like TestNG or JUnit. Basically I dont need TestNG or Junit for that matter as I handling whole framework getting the data from an excel sheet.
Currently I am executing all the Test steps using Java Reflection. Test Steps are basically simple java methods. I have defined them inside a class - executing them one by one for each Test Case.
Example :
[TC_0001, login, createUser, ModifyUser, deletUser]
[TC_0002, createUser]
Executing each Test Case - TC_0001 by executing each Test Step one by one.
TestCase Id - TC_0001
Step 1 - createUser
Step 2 - modifyUser
Step 3 - deletUser
I have defined these methods in a java class and planning to add #Step annotation for Allure Report. Wondering if this is at all possible.
Example
#Step
public void login(String username, String password) {
//TestSetup.test.log(LogStatus.INFO, "This step shows the Login Function");
Log.info("Executing the Login method");
}
...
Looking at the Allure Documentation and report example I am interested to implement it in my framework for Test Reports.
However I am unable to do it. Is these any way I can achieve this without any TestNG or Junit adaptor ? Please refer my pom.xml below
<?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>
<parent>
<groupId>io.qameta</groupId>
<artifactId>opensource-parent</artifactId>
<version>1.3</version>
</parent>
<artifactId>allure-junit-example</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<allure.version>1.4.23.HOTFIX1</allure.version>
<aspectj.version>1.8.9</aspectj.version>
<compiler.version>1.7</compiler.version>
</properties>
<name>Allure JUnit Example</name>
<description>Allure JUnit and WebDriver Usage Example</description>
<dependencies>
<!-- Allure Junit Adaptor -->
<dependency>
<groupId>ru.yandex.qatools.allure</groupId>
<artifactId>allure-junit-adaptor</artifactId>
<version>${allure.version}</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.8-beta4</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.10-FINAL</version>
</dependency>
<!-- https://mvnrepository.com/artifact/log4j/log4j -->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.53.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<argLine>
-javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar"
</argLine>
<properties>
<property>
<name>listener</name>
<value>ru.yandex.qatools.allure.junit.AllureRunListener</value>
</property>
</properties>
</configuration>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>${aspectj.version}</version>
</dependency>
</dependencies>
</plugin>
<!--Needed only to show reports locally. Run jetty:run and
open localhost:8080 to show the report-->
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.2.10.v20150310</version>
<configuration>
<webAppSourceDirectory>${project.build.directory}/site/allure-maven-plugin</webAppSourceDirectory>
<stopKey>stop</stopKey>
<stopPort>1234</stopPort>
</configuration>
</plugin>
</plugins>
</build>
<!-- Allure Reporting -->
<reporting>
<excludeDefaults>true</excludeDefaults>
<plugins>
<plugin>
<groupId>ru.yandex.qatools.allure</groupId>
<artifactId>allure-maven-plugin</artifactId>
<version>2.5</version>
</plugin>
</plugins>
</reporting>
</project>
I did Maven clean install site jetty:run but unable to get the report. I am sure I am missing lot of things and any help on these is appreciated.
In short NO.
The Allure Reporting framework will work with any test framework for which the developers have defined an adapter, which is a small library that is attached to particular test frameworks and know how to extract test information to XML.
Please visit - https://github.com/allure-framework/allure1/wiki, for more information on how to setup your test with any of the available frameworks.
As far as your pom.xml goes, you seem to have used the allure-junit-adaptor with no version, i.e., ${allure.version}. How do you expect the dependency to be resolved without a version ?
In your example, there is #Step annotation which definitely is from allure, but in the absence of #Test from either TestNg or jUnit or for that matter any thing that specifies that the method is a TEST, Allure will not be able to generate the report because it will not be able to assert for which methods to extract test information to XML.
Once you have implemented the appropriate adapter, you can do - mvn clean test site, and when the test run finishes, just go to the site directory in your project, inside this open the folder which is named after whichever adapter you implemented, here you will find index.html, open this in a browser and you will be able to see the report with the results without running jetty.