7得票1回答
FakeItEasy说MustHaveHappened没有发生...但实际上是发生了。

我正在尝试对“服务层” / “应用程序门面层”方法进行单元测试。 这是我要进行单元测试的方法: // Create a new order in the database for a customer. Given a customer id, // will create a new o...

474得票10回答
如何使用Jest模拟ES6模块导入?

我想测试我的ES6模块是否以特定方式调用另一个ES6模块。使用Jasmine非常容易-- 应用程序代码: // myModule.js import dependency from './dependency'; export default (x) => { dependen...

8得票3回答
Mockito,测试依赖注入的对象(Spring)?

我是Mockito的新手,正在尝试理解一种依赖注入的类单元测试方法。我的目标是创建依赖的模拟对象,并让我要测试的类使用这些模拟对象,而不是Spring注入的常规依赖项。我已经阅读了一些教程,但对如何实现还有点困惑。 我要测试的类看起来像这样: package org.rd.server.b...

9得票1回答
EasyMock:模拟对象正在调用实际方法

我在单元测试中有以下代码片段: ClassToBeMocked mock = createMock(ClassToBeMocked.class); //I've statically imported EasyMock.* mock.callMethod(); //This is a voi...

18得票1回答
使用Mockito无法模拟CGLIB代理服务的属性

我在尝试模拟一个服务的属性时,遇到了问题:@ContextConfiguration("classpath:application-config.xml") @RunWith(SpringJUnit4ClassRunner.class) public class FooServiceTests...

21得票1回答
如何模拟一个装饰函数

因为测试的原因,我需要能够模拟另一处使用的修饰函数内部/原始函数: 在mydecorator.py文件中:def my_decorator(f): def wrapped_f(): print "decorated" f() return wr...

8得票2回答
Mocking - 无法实例化属性的代理类?

这是我的测试代码: [SetUp] public void Initialise() { mockOwinManager = new Mock<IOwinManager<ApplicationUser, ApplicationRole>>(); moc...

90得票3回答
模拟一个方法抛出异常(moq),但其他方面表现如同被模拟的对象?

我有一个Transfer类,简化后看起来像这样:public class Transfer { public virtual IFileConnection source { get; set; } public virtual IFileConnection destinat...

17得票2回答
使用phpunit模拟抽象类中的具体方法

有没有好的方法可以使用PHPUnit模拟抽象类中的具体方法? 目前我找到的解决方案有: - expects() ->will() 可以很好地用于抽象方法。 - 但是对于具体方法,它不起作用。原始方法仍会运行。 - 使用MockBuilder并将所有抽象方法和具体方法传递给setMethod...

15得票2回答
如何在Mockito中模拟instanceof

我有一段代码,想要使用Mockito进行测试:mockedClass instanceof SampleInterface mockedClass 是被模拟的抽象类:MockedClass,而 SampleInterface 是一个接口。这是失败的关键点:Validate.isTrue(moc...