无法通过终端|来运行maven测试无法执行目标

时间:2018-06-13 21:50:47

标签: java linux maven ssl appium

我正在尝试使用maven在终端中运行我的单元测试。

当我运行 @Configuration public class WebSecurityConfig extends WebSecurityConfigurerAdapter { @Autowired private PermissionEvaluator permissionEvaluator; @Override public void configure(WebSecurity web) throws Exception { DefaultWebSecurityExpressionHandler handler = new DefaultWebSecurityExpressionHandler(); handler.setPermissionEvaluator(permissionEv); web.expressionHandler(handler); } @Override protected void configure(HttpSecurity http) throws Exception { .... } mvn clean test时,我得到以下输出:

mvn test

我还尝试使用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 运行单个测试,但我得到了同样的错误。

这是我的pom.xml文件:

mvn test -Dtest=testname

以下是我的一项测试示例:

<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>

第二次编辑: 这是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(); }

的输出
mvn dependency::tree

第三次编辑: 我可以在我的Windows 10机器上成功运行[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 ,它按预期工作。我的Ubuntu 18.04计算机上存在此问题。

我可以采取哪些措施来解决这个问题?我通常在intellij想法中运行我的测试,它们运行得很好。但我需要准备好在Microsoft App Center中上传这些测试。

1 个答案:

答案 0 :(得分:0)

Ubuntu 18.04存在问题。

我运行了sudo rm / etc / ssl / certs / java / cacerts,然后运行了sudo update-ca-certificates -f,这解决了我在kubuntu 18.04中的问题。