AutomatedOwl / allure-environment-writer

Java library which allows to write environment.xml file into allure-results directory.
Apache License 2.0
24 stars 5 forks source link

ENV not visible #1

Open dudziakm opened 5 years ago

dudziakm commented 5 years ago

Hello, I am trying to use this solution :) I have test project with Java + Selenium + Gradle + TestNg.

Gradle: compile group: 'com.github.automatedowl', name: 'allure-environment-writer', version: '1.0.0' testCompile group: 'com.github.automatedowl', name: 'allure-environment-writer', version: '1.0.0'

Code: @BeforeSuite void setAllureEnvironment() { allureEnvironmentWriter( ImmutableMap.<String, String>builder() .put("Browser", "Chrome") .put("Browser.Version", "70.0.3538.77") .put("URL", "http://testjs.site88.net") .build()); }

And I see no information about the environment now :(

AutomatedOwl commented 5 years ago

Please attach code sample or the whole repo if possible for bug reproduction. Please attach any received exception. @dudziakm

dudziakm commented 5 years ago

I just copy-pasted your solution: https://github.com/AutomatedOwl/allure-environment-writer#example-of-common-usage-default-path-is-targetallure-results there was no issue or exception :(

AutomatedOwl commented 5 years ago

clone the whole repository and run with 'mvn test'. then check allure report and see the values.

gabrielstar commented 4 years ago

I had the same issue although with junit. After adding

com.github.automatedowl allure-environment-writer 1.0.0

to my pom (https://github.com/gabrielstar/selenide-allure-junit) file and attempted to use like this:

public class BaseTests {
    static {
        setAllureEnvironment();
    }
    private static void setAllureEnvironment() {
        allureEnvironmentWriter(
                ImmutableMap.<String, String>builder()
                        .put("Browser", "Chrome")
                        .put("Browser.Version", "70.0.3538.77")
                        .put("URL", "http://testjs.site88.net")
                        .build(), System.getProperty("user.dir")
                        + "/target/allure-results/");
    }
}

Allure results stopped to be generated to target/ in xml format and were generated to root of the project instead in json format. I also noticed that though I downloaded junit-selenide-allure I had testng attempt from surefire in pom which is surprising (it was there from beginning)

TestNG] [ERROR] No test suite found. Nothing to run
Usage: <main class> [options] The XML suite files to run

I solved both of those issues by forcing surefire to explicitely use junit provider to run tests as oppose to testng:

<plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.22.2</version>
                <configuration>
                    <testFailureIgnore>false</testFailureIgnore>
                    <argLine>
                        -javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar"
                        -DBUILD_URL=${BUILD_URL}
                    </argLine>
                    <properties>
                        <property>
                            <name>listener</name>
                            <value>ru.yandex.qatools.allure.junit.AllureRunListener</value>
                        </property>
                    </properties>
                </configuration>
                <dependencies>

                    <dependency>
                        <groupId>org.apache.maven.surefire</groupId>
                        <artifactId>surefire-junit47</artifactId>
                        <version>3.0.0-M3</version>
                    </dependency>

                    <dependency>
                        <groupId>org.aspectj</groupId>
                        <artifactId>aspectjweaver</artifactId>
                        <version>${aspectj.version}</version>
                    </dependency>
                </dependencies>
            </plugin>

Though your issue is not 100% the same, perhaps this line of thought could help you.