English 中文(简体)
2. 设定目标
原标题:Scala Mock Object Creation

是否有办法制造某种特定类型的物体,而该物体超越了一种替代方法,并对其他方法排出暂时的例外?

甚至没有必要获得超级阶级的任何执行。 在汇编时间和操作时间方面,它只是需要同样的类型。

最佳回答

相对而言,“ScalaMock。 粉碎物在盒子中的确存在,即,你对无论期望告诉他们做什么都寄予期望的方法,所有其他人都寄出一种怀疑。

What s your use-case?

问题回答

As Paul said, ScalaMock is a good way to go.

但我要指出,你只是重新描述基本继承:

class OriginalClass {
  def methodToRun() = { println("called OriginalClass.methodToRun") }
  def methodNotToRun() = { println("called OriginalClass.methodNotToRun") }
}

class MockOriginalClass extends OriginalClass {
  override def methodToRun() = super.methodToRun()
  override def methodNotToRun() = throw new RuntimeException("you weren t supposed to run this!")
}

然后,在您的法典中,您希望通过<条码>原件Class。 职等,如果你说错的话,就会犯错误。





相关问题
SoapUI Groovy 方言

我试图阅读即将提出的申请,并根据请求中价值分立的3.0作出模拟反应。 我为此使用了以下大写。

Mocking Entity Context in EF4

I am using VS2010 B2 and EF4 B2 and trying to use Rhino Mocks to mock the entity context generated by EEF. var context = MockRepository.GenerateMock<SomeDBEntities>(); IObjectSet<TxMode> ...

Google Mock for iPhone development?

I have an interesting situation where I am refactoring a bunch of ObjC iPhone code to create a C++ API. I m a novice to C++ and looking into C++ mocking frameworks to augment the work I d done using ...

StrucutureMap RhinoMock Record/Playback, Example needed

I m looking for some examples on how to do the following Mock Tests using StructureMap or Unity with NUnit. I have the following code structure public interface IDAL { List<Model> Method1(...

Easiest way to deal with sample data in Java web apps?

I m writing a Java web app in my free time to learn more about development. I m using the Stripes framework and eventually intend to use hibernate and MySQL For the moment, whilst creating the pages ...

Elegant design of simulating a read-only object

I am currently developing an GUI to an embedded system. (I am using GUI to descripe my app opposed to interface to avoid confusion with the progamatic meaning) Context I have created a class which ...

热门标签