1
votes

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.

1

1 Answers

1
votes

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.