1

I am trying to use maven to run my unit tests in terminal.

When I run mvn clean test or mvn test I get the following output:

user@user:~/Documents/git/projectname$ mvn test
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.google.inject.internal.cglib.core.$ReflectUtils$1 (file:/usr/share/maven/lib/guice.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
WARNING: Please consider reporting this to the maintainers of com.google.inject.internal.cglib.core.$ReflectUtils$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
[INFO] Scanning for projects...
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] Building project name 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ projectname ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 1 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ projectname ---
[INFO] No sources to compile
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ projectname ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 1 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ projectname ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ projectname ---
[INFO] Surefire report directory: /home/user/Documents/git/QA-projectname/target/surefire-reports
Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/surefire/surefire-junit4/2.12.4/surefire-junit4-2.12.4.pom
[INFO] Failure detected.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.258 s
[INFO] Finished at: 2018-06-13T15:36:31-06:00
[INFO] Final Memory: 13M/54M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test (default-test) on project projectname: Unable to generate classpath: org.apache.maven.artifact.resolver.ArtifactResolutionException: Unable to get dependency information for org.apache.maven.surefire:surefire-junit4:jar:2.12.4: Failed to retrieve POM for org.apache.maven.surefire:surefire-junit4:jar:2.12.4: Could not transfer artifact org.apache.maven.surefire:surefire-junit4:pom:2.12.4 from/to central (https://repo.maven.apache.org/maven2): java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty
[ERROR]   org.apache.maven.surefire:surefire-junit4:jar:2.12.4
[ERROR] 
[ERROR] from the specified remote repositories:
[ERROR]   central (https://repo.maven.apache.org/maven2, releases=true, snapshots=false)
[ERROR] Path to dependency: 
[ERROR]     1) dummy:dummy:jar:1.0
[ERROR] 
[ERROR] 
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

I have also tried to run a single test with mvn test -Dtest=testname but I get the same error.

Here is my pom.xml file:

<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>groupidhere</groupId>
  <artifactId>artifactidhere</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <dependencies>
    <dependency>
     <groupId>io.appium</groupId>
     <artifactId>java-client</artifactId>
     <version>4.0.0</version>
    </dependency>
   <dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>4.11</version>
   </dependency>
      <dependency>
          <groupId>com.google.guava</groupId>
          <artifactId>guava</artifactId>
          <version>21.0</version>
      </dependency>
      <dependency>
          <groupId>org.seleniumhq.selenium</groupId>
          <artifactId>selenium-java</artifactId>
          <version>3.0.1</version>
      </dependency>
      <dependency>
          <groupId>org.apache.maven.surefire</groupId>
          <artifactId>surefire</artifactId>
          <version>2.21.0</version>
          <type>pom</type>
      </dependency>
  </dependencies>
  <properties>
      <maven.compiler.source>1.8</maven.compiler.source>
      <maven.compiler.target>1.8</maven.compiler.target>
  </properties>
  <name>Small Store Regression</name>
  <description>description here</description>
</project>

Here is an example of one of my tests:

package loginPurchase;

import org.junit.AfterClass;
import org.junit.Before;
import org.junit.Test;
import PageObjects.CartScreen;
import PageObjects.HomeScreen;
import testBase.TestBase;
import java.math.BigDecimal;
import static org.junit.Assert.assertTrue;

public class ProductTaxPurchases extends TestBase {

    @Before
    public void setUp() throws Exception {
        mobileSetup();
    }

    @AfterClass
    public static void tearDown() throws Exception {
        mdriver.quit();
        mdriver = null;
    }

    //The purpose of this test is to add a taxed product to a cart and verify the taxes are correct | and purchase by CC
    @Test
    public void purchaseTaxedProductByCredit() throws InterruptedException {
        HomeScreen hs = new HomeScreen(mdriver);
        CartScreen cs = new CartScreen(mdriver);

        hs.clickMenu("TestMenuB")
                .clickMenuItem("ChrisTaxProduct");

        String subTotal = cs.getSubTotal();
        String taxAmount = cs.getTax();
        String grandTotal = cs.getGrandTotal();

        BigDecimal currentSubTotal = new BigDecimal(subTotal);
        BigDecimal currentTaxTotal = new BigDecimal(taxAmount);
        BigDecimal currentGrandTotal = new BigDecimal(grandTotal);

        BigDecimal expectedGrandTotal = currentSubTotal.add(currentTaxTotal);

        assertTrue(currentGrandTotal.compareTo(expectedGrandTotal) == 0);

        cs.clickPayByCreditCard()
                .swipeApprovedCard()
                .clickNoReceipt();

    }

Second Edit: Here is the output of mvn dependency::tree

[ERROR] No plugin found for prefix 'dependency' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (/home/chris/.m2/repository), central (https://repo.maven.apache.org/maven2)] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/NoPluginFoundForPrefixException

Third edit: I can successfully run mvn clean test on my windows 10 machine and it works as expected. This problem exists on my Ubuntu 18.04 machine.

Any ideas of what I can do to fix this? I normally run my tests in intellij idea and they run just fine. But I am needing to get these tests ready for upload in Microsoft App Center.

Chris
  • 123
  • 1
  • 1
  • 21
  • Although the error occurs inside the running of maven, it is a Java error related to secure connections (SSL). Check: https://stackoverflow.com/questions/6784463/error-trustanchors-parameter-must-be-non-empty/25188331#25188331 – Rafael Odon Jun 14 '18 at 00:15
  • I tried most of the "solutions" from that thread, and nothing has changed.. – Chris Jun 14 '18 at 01:32
  • probably you need to update maven dependencies, FOLLOW: https://stackoverflow.com/questions/13170860/failed-to-execute-goal-org-apache-maven-pluginsmaven-surefire-plugin2-10test – Kushal Bhalaik Jun 14 '18 at 05:11
  • I have still been unable to solve this.. – Chris Jun 15 '18 at 16:43
  • `the trustAnchors parameter must be non-empty` This is the same as: https://stackoverflow.com/questions/6784463/error-trustanchors-parameter-must-be-non-empty#answer-6788682 – Jake Johnson Jun 15 '18 at 17:04

1 Answers1

0

The problem exists with Ubuntu 18.04.

I ran sudo rm /etc/ssl/certs/java/cacerts and then sudo update-ca-certificates -f and this fixed my issue in kubuntu 18.04.

Chris
  • 123
  • 1
  • 1
  • 21