stub

Difference between Mock / Stub / Spy in Spock test framework

帅比萌擦擦* 提交于 2019-11-26 18:48:37
问题 I don't understand the difference between Mock, Stub, and Spy in Spock testing and the tutorials I have been looking at online don't explain them in detail. 回答1: Attention: I am going to oversimplify and maybe even slightly falsify in the upcoming paragraphs. For more detailed info see Martin Fowler's website. A mock is a dummy class replacing a real one, returning something like null or 0 for each method call. You use a mock if you need a dummy instance of a complex class which would

What's the difference between a mock & stub?

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-26 01:09:43
问题 I\'ve read various articles about mocking vs stubbing in testing, including Martin Fowler\'s Mocks Aren\'t Stubs, but still don\'t understand the difference. 回答1: Stub I believe the biggest distinction is that a stub you have already written with predetermined behavior. So you would have a class that implements the dependency (abstract class or interface most likely) you are faking for testing purposes and the methods would just be stubbed out with set responses. They would not do anything

What's the difference between faking, mocking, and stubbing?

隐身守侯 提交于 2019-11-26 00:29:21
问题 I know how I use these terms, but I\'m wondering if there are accepted definitions for faking , mocking , and stubbing for unit tests? How do you define these for your tests? Describe situations where you might use each. Here is how I use them: Fake : a class that implements an interface but contains fixed data and no logic. Simply returns \"good\" or \"bad\" data depending on the implementation. Mock : a class that implements an interface and allows the ability to dynamically set the values

Access restriction on class due to restriction on required library rt.jar?

巧了我就是萌 提交于 2019-11-25 22:24:36
问题 I\'m attempting to compile Java 1.4 code that was created by IBM\'s WSDL2Java on Java5 without recreating the stubs and saw this error in Eclipse. I\'m under the assumption that the stubs generated should just compile as long as the runtime jars are available (they are). Access restriction: The type QName is not accessible due to restriction on required library C:\\Program Files\\Java\\jdk1.5.0_16\\jre\\lib\\rt.jar The full class name is javax.xml.namespace.QName What exactly is going on here

When to Expect and When to Stub?

微笑、不失礼 提交于 2019-11-25 15:18:25
I use NMock2, and I've drafted the following NMock classes to represent some common mock framework concepts: Expect : this specifies what a mocked method should return and says that the call must occur or the test fails (when accompanied by a call to VerifyAllExpectationsHaveBeenMet() ). Stub : this specifies what a mocked method should return but cannot cause a test to fail. So which should I do when? A lot of mocking frameworks are bringing the concepts of mocks & stubs closer & closer together to the point that they can be considered functionally almost the same. From a conceptual