zoukankan      html  css  js  c++  java
  • 学习笔记-[Maven实战]-第三章:Maven使用入门(2)

    使用maven执行编译和测试

    1.maven执行编译

      (1).在pom.xml上点右键,选择Maven build...

           

      (2).在Goals里输入clean complie,执行编译

      

      执行结果:

    [INFO] Scanning for projects...
    [INFO]                                                                         
    [INFO] ------------------------------------------------------------------------
    [INFO] Building helloworld 0.0.1-SNAPSHOT
    [INFO] ------------------------------------------------------------------------
    [INFO]
    [INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ helloworld ---
    [INFO] Deleting D:ProgramData3workhelloworld arget
    [INFO]
    [INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ helloworld ---
    [debug] execute contextualize
    [INFO] Using 'UTF-8' encoding to copy filtered resources.
    [INFO] skip non existing resourceDirectory D:ProgramData3workhelloworldsrcmain esources
    [INFO]
    [INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ helloworld ---
    [INFO] Compiling 1 source file to D:ProgramData3workhelloworld argetclasses
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD SUCCESS
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 1.047s
    [INFO] Finished at: Tue Jul 16 17:50:51 CST 2013
    [INFO] Final Memory: 5M/15M
    [INFO] ------------------------------------------------------------------------

    2.Maven执行测试

      (1).在pom.xml执行maven test,如图

        

      执行结果

    [INFO] Scanning for projects...
    [INFO]                                                                         
    [INFO] ------------------------------------------------------------------------
    [INFO] Building helloworld 0.0.1-SNAPSHOT
    [INFO] ------------------------------------------------------------------------
    [INFO]
    [INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ helloworld ---
    [debug] execute contextualize
    [INFO] Using 'UTF-8' encoding to copy filtered resources.
    [INFO] skip non existing resourceDirectory D:ProgramData3workhelloworldsrcmain esources
    [INFO]
    [INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ helloworld ---
    [INFO] Nothing to compile - all classes are up to date
    [INFO]
    [INFO] --- maven-resources-plugin:2.5:testResources (default-testResources) @ helloworld ---
    [debug] execute contextualize
    [INFO] Using 'UTF-8' encoding to copy filtered resources.
    [INFO] skip non existing resourceDirectory D:ProgramData3workhelloworldsrc est esources
    [INFO]
    [INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ helloworld ---
    [INFO] Compiling 1 source file to D:ProgramData3workhelloworld arget est-classes
    [INFO]
    [INFO] --- maven-surefire-plugin:2.10:test (default-test) @ helloworld ---
    [INFO] Surefire report directory: D:ProgramData3workhelloworld argetsurefire-reports

    -------------------------------------------------------
     T E S T S
    -------------------------------------------------------
    Running com.juvenxu.helloworld.AppTest
    Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.046 sec <<< FAILURE!

    Results :

    Failed tests:   sayHello(com.juvenxu.helloworld.AppTest): expected:<hello[1]> but was:<hello[]>

    Tests run: 1, Failures: 1, Errors: 0, Skipped: 0

    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD FAILURE
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 1.750s
    [INFO] Finished at: Tue Jul 16 17:53:20 CST 2013
    [INFO] Final Memory: 6M/15M
    [INFO] ------------------------------------------------------------------------
    [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.10:test (default-test) on project helloworld: There are test failures.
    [ERROR]
    [ERROR] Please refer to D:ProgramData3workhelloworld argetsurefire-reports for the individual test results.
    [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/MojoFailureException

    执行失败,因为类方法返回的是"hello",而我在测试类里写的是"hello1",所以失败了,修改一下测试代码就OK了

  • 相关阅读:
    2014年10月28~10月30日,某大型医疗企业产品管理和产品经理体系建设咨询项目调研启动!
    2014年8月4~6日, 杨学明老师《软件需求和测试质量管理》内训在北京某大型国企成功举办!
    2014年11月17~11月18日,杨学明老师《企业IT需求收集和实施》内训在湖南长沙某酒店成功举办!
    2014年11月12~11月14日,杨学明老师《软件测试管理》内训在北京某银行软件中心成功举办!
    2014年10月17~10月18日,杨学明老师《软件测试管理》实战班公开课在北京成功举办!
    2014年10月31~11月1日,杨学明老师《新产品开发流程优化和项目管理》内训课程在中山某企业成功举办!
    2014年9月19~20日,杨学明老师《软件测试管理》公开课(杭州站)成功举办!
    2014年9月12~13日,杨学明老师《软件质量管理》公开课(深圳站)成功举办!
    2014年7月23日, 杨学明老师《产品测试管理》内训课程在东莞市松山湖某大型企业成功举办!
    2014年7月11~12日,杨学明老师《软件测试管理》公开课(深圳站)成功举办!
  • 原文地址:https://www.cnblogs.com/lost0/p/3193875.html
Copyright © 2011-2022 走看看