Search code examples
selenium-webdrivertestngallurebrowsermob

Browsermob dependecy insertion cannot work with allure testng


I'm trying to change requests headers using browsermob, but I can't even insert the dependency. I don't know if there are any incompatibilities between allure and browsermob, I already tried to downgrade the allure version and really I have no clue about what is happening.

<dependency>
   <groupId>net.lightbody.bmp</groupId>
   <artifactId>browsermob-core</artifactId>
   <version>2.1.5</version>
   <scope>test</scope>
</dependency>

Just inserting this dependency and running my basic test I get the below error messages:

[ERROR] org.testng.ITestNGListener: Provider io.qameta.allure.testng.AllureTestNg could not be instantiated [INFO] [INFO] Results: [INFO] [INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0 [INFO] [ERROR] There are test failures.

Please refer to /mypath/my-project/target/surefire-reports for the individual test results. Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream. There was an error in the forked processorg.testng.ITestNGListener: Provider io.qameta.allure.testng.AllureTestNg could not be instantiated org.apache.maven.surefire.booter.SurefireBooterForkException: There was an error in the forked processorg.testng.ITestNGListener: Provider io.qameta.allure.testng.AllureTestNg could not be instantiated at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:675) at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:285) at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:248) at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeProvider(AbstractSurefireMojo.java:1217) at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked(AbstractSurefireMojo.java:1063) at org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute(AbstractSurefireMojo.java:889) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:210) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:156) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81) at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:305) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105) at org.apache.maven.cli.MavenCli.execute(MavenCli.java:956) at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288) at org.apache.maven.cli.MavenCli.main(MavenCli.java:192) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289) at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415) at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)

Here is my pom:

<?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">
   <artifactId>my-project</artifactId>
   <build>
      <plugins>
         <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
               <source>11</source>
               <target>11</target>
            </configuration>
            <groupId>org.apache.maven.plugins</groupId>
            <version>3.6.0</version>
         </plugin>
         <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
               <testFailureIgnore>true</testFailureIgnore>
               <argLine>-javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar"</argLine>
               <systemPropertyVariables>
                  <java.awt.headless>true</java.awt.headless>
               </systemPropertyVariables>
            </configuration>
            <dependencies>
               <dependency>
                  <groupId>org.aspectj</groupId>
                  <artifactId>aspectjweaver</artifactId>
                  <version>${aspectj.version}</version>
               </dependency>
            </dependencies>
            <version>3.0.0-M4</version>
         </plugin>
      </plugins>
   </build>
   <dependencies>
      <!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
      <dependency>
         <artifactId>selenium-java</artifactId>
         <groupId>org.seleniumhq.selenium</groupId>
         <version>3.141.59</version>
      </dependency>
      <!-- https://mvnrepository.com/artifact/junit/junit -->
      <dependency>
         <artifactId>junit</artifactId>
         <groupId>junit</groupId>
         <scope>compile</scope>
         <version>4.13-rc-2</version>
      </dependency>
      <!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
      <dependency>
         <artifactId>commons-io</artifactId>
         <groupId>commons-io</groupId>
         <version>2.6</version>
      </dependency>
      <!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-surefire-plugin -->
      <dependency>
         <artifactId>maven-surefire-plugin</artifactId>
         <groupId>org.apache.maven.plugins</groupId>
         <version>3.0.0-M4</version>
      </dependency>
      <!-- https://mvnrepository.com/artifact/org.testng/testng -->
      <dependency>
         <artifactId>testng</artifactId>
         <groupId>org.testng</groupId>
         <scope>compile</scope>
         <version>7.1.0</version>
      </dependency>
      <!-- https://github.com/allure-framework/allure2/releases/tag/2.13.2 -->
      <dependency>
         <artifactId>allure-testng</artifactId>
         <groupId>io.qameta.allure</groupId>
         <scope>test</scope>
         <version>2.13.2</version>
      </dependency>
      <dependency>
         <artifactId>gson</artifactId>
         <groupId>com.google.code.gson</groupId>
         <version>2.8.2</version>
      </dependency>
      <dependency>
         <artifactId>allure-java-commons</artifactId>
         <groupId>io.qameta.allure</groupId>
         <scope>compile</scope>
         <version>2.13.2</version>
      </dependency>
      <!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core -->
      <dependency>
         <artifactId>log4j-core</artifactId>
         <groupId>org.apache.logging.log4j</groupId>
         <version>2.13.1</version>
      </dependency>
      <!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-api -->
      <dependency>
         <artifactId>log4j-api</artifactId>
         <groupId>org.apache.logging.log4j</groupId>
         <version>2.13.1</version>
      </dependency>
      <!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-slf4j-impl -->
      <dependency>
         <artifactId>log4j-slf4j-impl</artifactId>
         <groupId>org.apache.logging.log4j</groupId>
         <scope>test</scope>
         <version>2.13.1</version>
      </dependency>
      <!-- https://mvnrepository.com/artifact/org.fusesource.jansi/jansi -->
      <dependency>
         <artifactId>jansi</artifactId>
         <groupId>org.fusesource.jansi</groupId>
         <version>1.18</version>
      </dependency>
      <dependency>
         <groupId>io.github.bonigarcia</groupId>
         <artifactId>webdrivermanager</artifactId>
         <version>3.8.1</version>
         <scope>compile</scope>
      </dependency>
      <!-- https://mvnrepository.com/artifact/net.lightbody.bmp/browsermob-proxy -->
      <dependency>
         <groupId>net.lightbody.bmp</groupId>
         <artifactId>browsermob-core</artifactId>
         <version>2.1.5</version>
         <scope>test</scope>
      </dependency>
   </dependencies>
   <groupId>org.example</groupId>
   <modelVersion>4.0.0</modelVersion>
   <properties>
      <aspectj.version>1.9.5</aspectj.version>
      <maven.compiler.source>11</maven.compiler.source>
      <maven.compiler.target>11</maven.compiler.target>
      <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
   </properties>
   <reporting>
      <excludeDefaults>true</excludeDefaults>
      <plugins>
         <plugin>
            <artifactId>allure-maven</artifactId>
            <configuration>
               <reportVersion>2.10.0</reportVersion>
            </configuration>
            <groupId>io.qameta.allure</groupId>
            <version>2.10.0</version>
         </plugin>
      </plugins>
   </reporting>
   <version>1.0-SNAPSHOT</version>
</project>

Solution

  • Did you find an answer to your issue? I just had the same problem, and after hours of research, I fixed it by just reordering dependencies in pom.xml file: your dependencies to allure MUST be below your dependencies to browserMobProxy in the file... for a reason I can't explain.

    So I think this would work for you:

    <?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">
       <artifactId>my-project</artifactId>
       <build>
          <plugins>
             <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                   <source>11</source>
                   <target>11</target>
                </configuration>
                <groupId>org.apache.maven.plugins</groupId>
                <version>3.6.0</version>
             </plugin>
             <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                   <testFailureIgnore>true</testFailureIgnore>
                   <argLine>-javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar"</argLine>
                   <systemPropertyVariables>
                      <java.awt.headless>true</java.awt.headless>
                   </systemPropertyVariables>
                </configuration>
                <dependencies>
                   <dependency>
                      <groupId>org.aspectj</groupId>
                      <artifactId>aspectjweaver</artifactId>
                      <version>${aspectj.version}</version>
                   </dependency>
                </dependencies>
                <version>3.0.0-M4</version>
             </plugin>
          </plugins>
       </build>
       <dependencies>
          <!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
          <dependency>
             <artifactId>selenium-java</artifactId>
             <groupId>org.seleniumhq.selenium</groupId>
             <version>3.141.59</version>
          </dependency>
          <!-- https://mvnrepository.com/artifact/junit/junit -->
          <dependency>
             <artifactId>junit</artifactId>
             <groupId>junit</groupId>
             <scope>compile</scope>
             <version>4.13-rc-2</version>
          </dependency>
          <!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
          <dependency>
             <artifactId>commons-io</artifactId>
             <groupId>commons-io</groupId>
             <version>2.6</version>
          </dependency>
          <!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-surefire-plugin -->
          <dependency>
             <artifactId>maven-surefire-plugin</artifactId>
             <groupId>org.apache.maven.plugins</groupId>
             <version>3.0.0-M4</version>
          </dependency>
          <!-- https://mvnrepository.com/artifact/org.testng/testng -->
          <dependency>
             <artifactId>testng</artifactId>
             <groupId>org.testng</groupId>
             <scope>compile</scope>
             <version>7.1.0</version>
          </dependency>
    <!-- https://mvnrepository.com/artifact/net.lightbody.bmp/browsermob-proxy -->
          <dependency>
             <groupId>net.lightbody.bmp</groupId>
             <artifactId>browsermob-core</artifactId>
             <version>2.1.5</version>
             <scope>test</scope>
          </dependency>
          <!-- https://github.com/allure-framework/allure2/releases/tag/2.13.2 -->
          <dependency>
             <artifactId>allure-testng</artifactId>
             <groupId>io.qameta.allure</groupId>
             <scope>test</scope>
             <version>2.13.2</version>
          </dependency>
          <dependency>
             <artifactId>gson</artifactId>
             <groupId>com.google.code.gson</groupId>
             <version>2.8.2</version>
          </dependency>
          <dependency>
             <artifactId>allure-java-commons</artifactId>
             <groupId>io.qameta.allure</groupId>
             <scope>compile</scope>
             <version>2.13.2</version>
          </dependency>
          <!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core -->
          <dependency>
             <artifactId>log4j-core</artifactId>
             <groupId>org.apache.logging.log4j</groupId>
             <version>2.13.1</version>
          </dependency>
          <!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-api -->
          <dependency>
             <artifactId>log4j-api</artifactId>
             <groupId>org.apache.logging.log4j</groupId>
             <version>2.13.1</version>
          </dependency>
          <!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-slf4j-impl -->
          <dependency>
             <artifactId>log4j-slf4j-impl</artifactId>
             <groupId>org.apache.logging.log4j</groupId>
             <scope>test</scope>
             <version>2.13.1</version>
          </dependency>
          <!-- https://mvnrepository.com/artifact/org.fusesource.jansi/jansi -->
          <dependency>
             <artifactId>jansi</artifactId>
             <groupId>org.fusesource.jansi</groupId>
             <version>1.18</version>
          </dependency>
          <dependency>
             <groupId>io.github.bonigarcia</groupId>
             <artifactId>webdrivermanager</artifactId>
             <version>3.8.1</version>
             <scope>compile</scope>
          </dependency>
       </dependencies>
       <groupId>org.example</groupId>
       <modelVersion>4.0.0</modelVersion>
       <properties>
          <aspectj.version>1.9.5</aspectj.version>
          <maven.compiler.source>11</maven.compiler.source>
          <maven.compiler.target>11</maven.compiler.target>
          <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
       </properties>
       <reporting>
          <excludeDefaults>true</excludeDefaults>
          <plugins>
             <plugin>
                <artifactId>allure-maven</artifactId>
                <configuration>
                   <reportVersion>2.10.0</reportVersion>
                </configuration>
                <groupId>io.qameta.allure</groupId>
                <version>2.10.0</version>
             </plugin>
          </plugins>
       </reporting>
       <version>1.0-SNAPSHOT</version>
    </project>