maven的单元测试中没有
原因:BaseTest没有找到单元测试造成的
增加一个空的单元测试
@Test
public void testNothing(){
} 异常现象:
在maven项目执行mvn install 或mvn test时报错: ERROR] Please refer to 目录/target/surefire-reports for the individual test results. 或者是运行单个单元测试时出现:java.lang.Exception: No runnable methods
本质一样。
-------------------------------------------
其他回答:
异常1:
[ERROR] Failed to execute goal on project biz_zhuhai: Could not resolve dependencies for project biz_zhuhai:biz_zhuhai:jar:0.0.1-SNAPSHOT: Failed to collect dependencies for [com.maywide.ibh:lib345:pom:1.0 (compile)]: Failed to read artifact descriptor for com.maywide.ibh:lib345:pom:1.0: Could not transfer artifact com.maywide.ibh:lib345:pom:1.0 from/to releases (http://localhost:9888/nexus-2.0.3/content/repositories/releases): Connection to http://localhost:9888 refused: Connection refused: connect -> [Help 1]
解决方法:
这是配置的url有错误或者是私服没有配好,导致构件下载时出错。如果没有jar包需要在私服里下载,可以不配置私服的,也就是可以把setting.xml的profiles里的东西全部删除的。
异常2:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.10:test (default-test) on project web_nanchang: There are test failures.
[ERROR]
[ERROR] Please refer to E:\maven\web_nanchang\target\surefire-reports for the individual test results.
解决方法:
这是因为测试代码时遇到错误,它会停止编译。只需要在pom.xml的<project>里添加以下配置,使得测试出错不影响项目的编译。
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<testFailureIgnore>true</testFailureIgnore>
</configuration>
</plugin>
</plugins>
</build>
异常3:
[ERROR] Failed to execute goal org.codehaus.cargo:cargo-maven2-plugin:1.0.6:start (start-Container) on project myproject: Execution start-container of goal org.codehaus.cargo:cargo-maven2-plugin:1.0.6:start failed: Error while expanding C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\cargo\installs\apache-tomcat-6.0.29.zip
[ERROR] Java.io.IOException: Negative seek offset
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit
ch.
[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 rea
d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutio
nException
解决方法:
自己下载“apache-tomcat-6.0.29.zip”,将下载好的文件拷贝到指定文件夹“C:\Documents and Settings\Administrator\Local Settings\Temp\cargo\installs”下。
异常4:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.1.1:war (default-war) on project web_nanchang: Error assembling WAR: webxml attribute is required (or pre-existing WEB-INF/web.xml if executing in update mode) -> [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:
解决方法:
maven的web项目默认的webroot是在src\main\webapp。如果在此目录下找不到web.xml就抛出以上的异常。解决方法在pom.xml加入以下的配置。红色字体改成你网站的根目录。
<build>
<finalName>simple-webapp</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<webResources>
<resource>
<!-- this is relative to the pom.xml directory -->
<directory>WebContent</directory>
</resource>
</webResources>
</configuration>
</plugin>
</plugins>
</build>
maven的单元测试中没有的更多相关文章
- 使用Maven运行单元测试
要通过Maven运行单元测试,发出此命令: mvn test 这会在你的项目中运行整个单元测试. 案例学习 创建两个单元测试,并通过 Maven 的运行它.参见一个简单的 Java 测试类: pack ...
- maven 学习---使用Maven运行单元测试
要通过Maven运行单元测试,发出此命令: mvn test 这会在你的项目中运行整个单元测试. 案例学习 创建两个单元测试,并通过 Maven 的运行它.参见一个简单的 Java 测试类: pack ...
- 单元测试:单元测试中的mock
公司要求提升单元测试的质量,提高代码的分支覆盖率和行覆盖率,安排我研究单元测试,指定方案分享并在开发部普及开.整理完资料后,同步一下到博客. 单元测试中的mock的目的 mock的主要目的是让单元测试 ...
- ASP.NET 5 单元测试中使用依赖注入
相关博文:<ASP.NET 5 使用 TestServer 进行单元测试> 在上一篇博文中,主要说的是,使用 TestServer 对 ASP.NET 5 WebApi 进行单元测试,依赖 ...
- 单元测试中如何配置log4net
按道理来说,单元测试中基本没有对于日志的需求,这是由于单元测试的定位来决定的. 因为单元测试的思想就是针对的都是小段代码的测试,逻辑明确,如果测试运行不通过,简单调试一下,就能很容易地排查问题.但是单 ...
- 单元测试中使用Moq对EF的DbSet进行mock
刚用上Moq,就用它解决了一个IUnitOfWork的mock问题,在这篇博文中记录一下. 开发场景 Application服务层BlogCategoryService的实现代码如下: public ...
- Java Web学习系列——Maven Web项目中集成使用Spring、MyBatis实现对MySQL的数据访问
本篇内容还是建立在上一篇Java Web学习系列——Maven Web项目中集成使用Spring基础之上,对之前的Maven Web项目进行升级改造,实现对MySQL的数据访问. 添加依赖Jar包 这 ...
- 使用Ninject+Moq在单元测试中抽象数据访问层
一.测试方法的业务逻辑时,通常都需要从数据库读取测试数据,但是每次初始化数据库数据都很麻烦,也会影响到其它业务对数据的访问,怎样抽象数据访问层呢?就是用Moq去模拟数据访问的逻辑 二.步骤如下 ...
- 如何在单元测试中测试异步函数,block回调这种
大概有四种方法: runloop 阻塞主进程等待结果 semphaore 阻塞主进程等待结果 使用XCTestExpectation 阻塞主线程等待(我用这个,xcode自带的,为啥不用) 使用第三方 ...
随机推荐
- python,接口自动化有几大类
python自动化: 1.接口测试 2.python 3.接口自动化框架 4.前端 html js css 5.web端的自动化 6.移动端 ios.Android 7.面试.简历 接口自动化(要会写 ...
- noj电子老鼠走迷宫(深搜dfs)超时错误
1042.电子老鼠闯迷宫 时限:1000ms 内存限制:10000K 总时限:3000ms 描述 有一只电子老鼠被困在如下图所示的迷宫中.这是一个12*12单元的正方形迷宫,黑色部分表示建筑物,白色 ...
- vue 关于solt得用法
solt 第一种用法 父组件 <templateSolt></templateSolt> <templateSolt> <p>slot分发了内容< ...
- [Spring Boot]什么是Spring Boot
<Spring Boot是什么> Spring Boot不是一个框架 是一种用来轻松创建具有最小或零配置的独立应用程序的方式 用来开发基于Spring的应用,但只需非常少的配置. 它提供了 ...
- IO调度算法的理解(转载)
IO调度器(IO Scheduler)是操作系统用来决定块设备上IO操作提交顺序的方法.存在的目的有两个,一是提高IO吞吐量,二是降低IO响应时间.然而IO吞吐量和IO响应时间往往是矛盾的,为了尽量平 ...
- Java EE 课程目标
对于自己在本门课程的目标,首先是跟进老师的课程进度,努力完成老师下达的个人任务,以及需要与同伴一起合力完成的团队任务:其次是在课上课下的学习过程中,希望自己各方面的能力能有所提升:最后却也是最重要的一 ...
- cocos2dx解决中文乱码方法
使用plist文件,优点方便做多国语言支持~也不用去做编码转换 1.Resource目录下新建text.plist文件,内容格式如下 <?xml version="1.0" ...
- oracle-logminer
LogMiner工具实际上是由两个新的PL/SQL内建包((DBMS_LOGMNR 和 DBMS_ LOGMNR_D)和四个V$动态性能视图(视图是在利用过程DBMS_LOGMNR.START_LOG ...
- 第三章 JQuery: HelloWorld--常见方法--css--选择器--筛选器--属性--效果--事件--数组操作--字符串操作--对象转换
1.jQuery简介 为了简化JavaScript 的开发, 一些JavsScript 库诞生了. JavaScript库封装了很多预定义的对象和实用函数.能帮助使用者建立有高难度交互的页面, 并且兼 ...
- 简单的shell脚本练习(一)
1:求1000一内的偶数和 方法一: #!/bin/bash #用累加实现1000以内的偶数和 sum= ;i<=;i=i+)) do sum=$(($sum+$i)); done echo $ ...