我的单元测试有问题,但我不知道原因。当我在eclipse中正常运行我的单元测试时,它运行的非常好。但是当我尝试使用ant构建我的项目时,有一个单元测试失败了。
我得到的唯一信息是测试失败了,我不知道为什么或者在哪条线上。
有没有办法让蚂蚁告诉我哪里出了问题(在哪条线上)?
这是我的单元测试目标:
<target name="unit.test"
depends="jar"
description="'jar', 'compile', and run unit tests
我正在编写一些使用Maven故障安全插件运行的Integration (ITs)。
简而言之,它们执行HTTP调用并分析JSON响应,以确保存在某些元素。
当测试失败时,我希望能够看到HTTP请求和响应(头、正文等)的细节,而不仅仅是断言失败消息。
如果我的测试像这样的话:
public class FooBarTest {
MyHttpClient httpClient;
@Before
public void setupHttpClient(){
this.httpClient = ...
}
@Test
public v
我有一堂课:
public class MyEncryptor {
private StringEncryptor stringEncryptor; // this is an interface ref
public void setStringEncryptor(StringEncryptor stringEncryptorImpl) {
if(condition){
this.stringEncryptor = stringEncryptorImpl;
}
}
}
在JUnit中测试方法setStri
我的类中有全局静态注册表,它在某些情况下注册实例。实际上,它并不依赖于垃圾收集,但是一些功能显然放在了finalize()中。
在jUnit测试期间,我希望测试这个功能是如何工作的,但我不能强制调用GC。我在我的tearDown()中调用gc()
@After
public void tearDown() throws Exception {
log.debug("tearDown()");
a = null;
b = null;
c = null;
d = null;
e = null;
f = null;
我有使用JAR的Java代码:
public class Version {
public String getVersion() {
// Use Java Package API to return information specified in the manifest of this JAR.
return getClass().getPackage().getImplementationVersion();
}
}
如何对此代码运行JUnit测试?
它在开发构建中失败(在Eclipse中),因为还没有JAR文件。
它在生产构建中失败(在
在Jenkins上运行build时,我遇到了以下异常,我的构建失败的场景是我项目的Integration部分。然而,我所有的junit和黄瓜测试用例在我的本地机器上工作得很好。
我在Jenkins服务器上收到的异常。
field - $jacocoData Exception is - java.beans.IntrospectionException: Method not found: is$jacocoData
我有一个java类,它可能分配很多数据。
我编写了一个junit测试,它应该检查内存泄漏,类似于下面的代码。
不幸的是,考试失败了。
@Test
public void shoudNotMemoryLeak()
{
Runtime runtime = Runtime.getRuntime();
// make shure that gc has collected all
System.gc ();
System.runFinalization ();
// memory before creating my sut
long memoryUs
我的问题是:是否有一种方法可以强迫Maven尽力而为(或JUnit)?在从test执行该类时,指示失败测试类的名称?
现在长话短说。
假设您有一个JUnit测试套件,它启动两个JUnit测试。
测试类示例:
public class TestOne {
@Test
public void foo() {
assertTrue(false);
}
@Test
public void bar() {
assertTrue(false);
}
}
@UnitTest
public class TestTwo {