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自带的,为啥不用) 使用第三方 ...
随机推荐
- (转)Web.config配置文件详解
花了点时间整理了一下ASP.NET Web.config配置文件的基本使用方法.很适合新手参看,由于Web.config在使用很灵活,可以自定义一些节点.所以这里只介绍一些比较常用的节点. <? ...
- xslfo和fop使用中的一些问题
最近项目中使用fop和xslfo打印pdf,遇到一些问题记录下来: 1.表格跨行.跨列: 使用number-rows-spanned和number-columns-spanned属性 比如:<f ...
- 利用Java获取ip地址
方法1 public static String getIp2(HttpServletRequest request) { String ip = request.getHeader("X- ...
- wpf-X名称空间Attribute
1.x:class 该属性用于 后台代码与前端xaml代码连接 代码实例如下图 2.x:ClassModifier 该属性用于控制可见级别 public 等 与C#中的可见级别相同 internal ...
- gitlab修改默认端口
部署gitlab的时候,一启动,发现80和8080端口已经被占用,无奈,只得先将监听80端口的nginx和监听8080端口的jenkins停止.这会儿有空,琢磨一下如何修改gitlab的默认端口. 修 ...
- Markdown最常用的几个语法
更多语法请参考:Markdown语法说明 http://wowubuntu.com/markdown/
- Go语言判断if else语句
基本格式: if 条件语句{ 执行语句 }else{ 执行语句 } package main import "fmt" func main(){ fmt.Println(Add(- ...
- 关于eclipse项目创建maven项目目录不正常的解决方案
最近学习ssh和maven,遇到了很多问题····首先一个很基础的问题就是我搭建的maven项目目录和教程上的不一样.我的目录之前是这样的: 而教程里的是这样的========> 因为是跟着视频 ...
- some working learning总结学习(二)
2. 读取excel上的测试用例和结果,成json格式,最终存到access数据库 结果如下: { : { 'Req_ID': 'Fqqqqq/qqqqq', 'Case_ID': 'ATC_LvPw ...
- 19/03/15Pyhon笔记
1.快速在python中显示目标的2进制写法 bin(342) "0b101010110" 2.一个二进制位就是一比特(bit) 3.Python2默认无法识别中文,需要加文件头 ...