Skip to content
Advertisement

Running from command line using “mvn test” gives error where dependency jar is not found

I have two projects. AutomationFramework is simply libraries/common pages/base class etc. I created a jar from it and added to the main test project which is the automation test suite. I can run from Eclipse (2021-06) all the 7 tests, successfully. I like to run them from command line and then set it up to run from Jenkins. When typed “mvn test” giving this error:

[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /C:/TFS/TS JAVA Automation/Development/FBRAutomationTestSuite/src/test/java/com/agricorp/FBRAutomationTestSuite/Pages/SelectAccrditedFarmOrganizationPage.java:[6,54] package com.agricorp.AutomationResourcesFramework.Base does not exist
[ERROR] /C:/TFS/TS JAVA Automation/Development/FBRAutomationTestSuite/src/test/java/com/agricorp/FBRAutomationTestSuite/Pages/SelectAccrditedFarmOrganizationPage.java:[7,57] package com.agricorp.AutomationResourcesFramework.Globals does not exist
[ERROR] /C:/TFS/TS JAVA Automation/Development/FBRAutomationTestSuite/src/test/java/com/agricorp/FBRAutomationTestSuite/Pages/SelectAccrditedFarmOrganizationPage.java:[8,57] package com.agricorp.AutomationResourcesFramework.Helpers does not exist
[ERROR] /C:/TFS/TS JAVA Automation/Development/FBRAutomationTestSuite/src/test/java/com/agricorp/FBRAutomationTestSuite/Pages/SelectAccrditedFarmOrganizationPage.java:[9,57] package com.agricorp.AutomationResourcesFramework.Helpers does not exist
[ERROR] /C:/TFS/TS JAVA Automation/Development/FBRAutomationTestSuite/src/test/java/com/agricorp/FBRAutomationTestSuite/Pages/SelectAccrditedFarmOrganizationPage.java:[11,58] cannot find symbol
  symbol: class Base
[ERROR] /C:/TFS/TS JAVA Automation/Development/FBRAutomationTestSuite/src/test/java/com/agricorp/FBRAutomationTestSuite/Pages/ReviewFarmBusinessInformationPage.java:[10,54] package com.agricorp.AutomationResourcesFramework.Base does not exist
[ERROR] /C:/TFS/TS JAVA Automation/Development/FBRAutomationTestSuite/src/test/java/com/agricorp/FBRAutomationTestSuite/Pages/ReviewFarmBusinessInformationPage.java:[11,57] package com.agricorp.AutomationResourcesFramework.Globals does not exist
[ERROR] /C:/TFS/TS JAVA Automation/Development/FBRAutomationTestSuite/src/test/java/com/agricorp/FBRAutomationTestSuite/Pages/ReviewFarmBusinessInformationPage.java:[12,57] package com.agricorp.AutomationResourcesFramework.Helpers does not exist
[ERROR] /C:/TFS/TS JAVA Automation/Development/FBRAutomationTestSuite/src/test/java/com/agricorp/FBRAutomationTestSuite/Pages/ReviewFarmBusinessInformationPage.java:[13,57] package com.agricorp.AutomationResourcesFramework.Helpers does not exist
[ERROR] /C:/TFS/TS JAVA Automation/Development/FBRAutomationTestSuite/src/test/java/com/agricorp/FBRAutomationTestSuite/Pages/ReviewFarmBusinessInformationPage.java:[14,57] package com.agricorp.AutomationResourcesFramework.Helpers does not exist
[ERROR] /C:/TFS/TS JAVA Automation/Development/FBRAutomationTestSuite/src/test/java/com/agricorp/FBRAutomationTestSuite/Pages/ReviewFarmBusinessInformationPage.java:[16,56] cannot find symbol
  symbol: class BasePageSetup

Error message

Btw, I have cleaned and compiled successfully (using mvn clean and mvn compile) from commandline. Aslo, I noticed that its looking for .java source files, above. “mvn verify” also gives above error.

By project setup in Eclipse”

Eclipse project structure

      <name>AutomationResourcesFramework</name>
      <!-- FIXME change it to the project's website -->
      <url>http://www.example.com</url>

      <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
      </properties>

      <dependencies>
        <!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>3.141.59</version>
        </dependency> 
        <!-- https://mvnrepository.com/artifact/io.github.bonigarcia/webdrivermanager -->
        <dependency>
            <groupId>io.github.bonigarcia</groupId>
            <artifactId>webdrivermanager</artifactId>
            <version>3.8.1</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core -->
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-core</artifactId>
            <version>2.14.1</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-api -->
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-api</artifactId>
            <version>2.14.1</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.testng/testng -->
        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>7.4.0</version>
            <!--scope>test</scope-->
        </dependency>
        <!-- https://mvnrepository.com/artifact/com.aventstack/extentreports -->
        <dependency>
            <groupId>com.aventstack</groupId>
            <artifactId>extentreports</artifactId>
            <version>5.0.8</version>
        </dependency>           
        <!-- https://mvnrepository.com/artifact/com.codoid.products/fillo -->
        <dependency>
            <groupId>com.codoid.products</groupId>
            <artifactId>fillo</artifactId>
            <version>1.21</version>
        </dependency>
      </dependencies>

        <profiles>
            <profile>
                <id>SanityTests</id>
                <build>
                    <plugins>
                        <plugin>
                            <groupId>org.apache.maven.plugins</groupId>
                            <artifactId>maven-surefire-plugin</artifactId>
                            <version>3.0.0-M5</version>
                            <configuration>
                                <suiteXmlFiles>
                                    <suiteXmlFile>testng.xml</suiteXmlFile>
                                </suiteXmlFiles>
                            </configuration>
                        </plugin>
                    </plugins>
                </build>
            </profile>
            <profile>
                <id>RegressionTests</id>
                <build>
                    <plugins>
                        <plugin>
                            <groupId>org.apache.maven.plugins</groupId>
                            <artifactId>maven-surefire-plugin</artifactId>
                            <version>3.0.0-M5</version>
                            <configuration>
                                <suiteXmlFiles>
                                    <suiteXmlFile>FBRAutomationTestSuite.xml</suiteXmlFile>
                                </suiteXmlFiles>
                            </configuration>
                        </plugin>
                    </plugins>
                </build>
            </profile>
        </profiles>

      <build>
        <pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
          <plugins>
            <!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
            <plugin>
              <artifactId>maven-clean-plugin</artifactId>
              <version>3.1.0</version>
            </plugin>
            <!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
            <plugin>
              <artifactId>maven-resources-plugin</artifactId>
              <version>3.0.2</version>
            </plugin>
            <plugin>
              <artifactId>maven-compiler-plugin</artifactId>
              <version>3.8.0</version>
            </plugin>
            <plugin>
              <artifactId>maven-jar-plugin</artifactId>
              <version>3.0.2</version>
            </plugin>
            <plugin>
              <artifactId>maven-install-plugin</artifactId>
              <version>2.5.2</version>
            </plugin>
            <plugin>
              <artifactId>maven-deploy-plugin</artifactId>
              <version>2.8.2</version>
            </plugin>
            <!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
            <plugin>
              <artifactId>maven-site-plugin</artifactId>
              <version>3.7.1</version>
            </plugin>
            <plugin>
              <artifactId>maven-project-info-reports-plugin</artifactId>
              <version>3.0.0</version>
            </plugin>
          </plugins>
        </pluginManagement>
      </build>
    </project>

Advertisement

Answer

AFAICS, there is no <dependency> in your FBRAutomationTestSuite project that refers to the AutomationResourcesFramework artifact, e.g. as an example:

        <dependency>
            <groupId>com.agricorp</groupId>
            <artifactId>automation-resources-framework</artifactId>
            <version>...</version>
        </dependency>
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement