Do OCUnit and OCMock work on the iPhone SDK?
I simply could not make it work, and I am wondering if I am wasting my time, or if I am simply stupid! Sorry I don't have the exact error I have right now. But I just want to know if it work or not! ...
I simply could not make it work, and I am wondering if I am wasting my time, or if I am simply stupid! Sorry I don't have the exact error I have right now. But I just want to know if it work or not! ...
I just wanna ask what would be better approach to supply these objects in my unit tests. In my unit test I am testing CSLA object. CSLA object is internally using one property and one method of ApplicationUser object. ApplicationUser is inherited from IPrincipal. The properties are: 1) ApplicationContext.User.IsInRole(...) - the method ...
I'm using jmockit with my tests and with one class I wish to test, uses InitialContext directly. So I have the following: public class MyClass { public void myMethod() { InitialContext ic = new InitialContext(); javax.mail.Session mailSession = ic.lookup("my.mail.session"); // rest of method follows..... } In my test ...
I read some of the answers on here re: testing views and controllers, and mocking, but I still can't figure out how to test an ASP.NET MVC controller that reads and sets Session values (or any other context based variables.) How do I provide a (Session) context for my test methods? Is mocking the answer? Anybody have examples? Basically,...
Hi all, Classes that use other classes (as members, or as arguments to methods) need instances that behave properly for unit test. If you have these classes available and they introduce no additional dependencies, isn't it better to use the real thing instead of a mock? ...
I am using Moq to mock my Repository layer so I can unit test. My repository layer Insert methods update the Id property of my entities when a successful db insert occurs. How do I configure moq to update the Id property of the entity when the Insert method is called? Repository code:- void IAccountRepository.InsertAccount(AccountE...
I've read (and re-read) Martin Fowler's Mocks Aren't Stubs. In it, he defines two different approaches to TDD: "Classical" and "Mockist". He attempts to answer the question "So should I be a classicist or a mockist?", but he admits that he has never tried mockist TDD on "anything more than toys." So I thought I'd ask the question here...
After reading Martin Fowler's Mocks Aren't Stubs, I've discovered I've been practicing TDD in the "mockist" fashion. But I'm wondering if even in mockist TDD if one can take mocking too far. Here's an updated example in Python-style pseudo-code: def sync_path(self): if self.confirm_or_create_connection(): self.sync(self.di...
Say I have class A with class A { final String foo() { // .. computing result, contacting database, whatever .. return "some computed value"; } // ... and a bazillion other methods, some of them final. } Now I have class B with class B { String methodIWantToTest(A a) { String output = a.foo(); // ... whate...
Here's my issue, I'd like to mock a class that creates a thread at initialization and closes it at destruction. There's no reason for my mock class to actually create and close threads. But, to mock a class, I have inherit from it. When I create a new instance of my mock class, the base classes constructor is called, creating the thre...
Is there any good book or material which covers C# unit testing using mocks in depth? ...
I am writing some JNI code in C that I wish to test using cunit. In order to call the JNI functions, I need to create a valid JNIEnv struct. Does anyone know if there is a mocking framework for such a purpose, or who can give me some pointers on how to create a mock JNIEnv struct myself? ...
I have a Java method which starts up a Process with ProcessBuilder, and pipes its output into a byte array, and then returns its byte array when the process is finished. Pseudo-code: ProcessBuilder b = new ProcessBuilder("my.exe") Process p = b.start(); ... // get output from process, close process What would be the best way to go ab...
My main JavaScript framework is jQuery so I would like my unit test and mocking frameworks to be compatible with that. I'd rather not have to introduce another JavaScript framework. I am currently using QUnit for unit testing and Jack for mocking, but I am pretty new to the whole unit testing of JavaScript. Does anyone else have a bett...
I just read the Wikipedia article on mock objects, but I'm still not entirely clear on their purpose. It appears they are objects that are created by a test framework when the actual object would be too complex or unpredictable (you know 100% sure what the values of the mock object are because you fully control them). However, I was und...
Hello all. I have a static method in my code that I would like somehow to mock. I am using jmock. One way I suppose I could do this is to have "wrapper class" around the static method and mock this but I was hoping for a better solution. I am going about this the wrong way? FEEDBACK: I was going to have a interface and class that h...
In my question As a “mockist” TDD practitioner, should I mock other methods in the same class as the method under test?, Avdi answered "Personally I think that mocking on self is almost always a code smell. It's testing the implementation rather than the behavior." He may be right, but often I can't distinguish between the implementatio...
I have the following class: public abstract class AbstractParent { static String method() { return "OriginalOutput"; } } I want to mock this method. I decide to use JMockit. So I create a mock class: public class MockParent { static String method() { return "MOCK"; } } And my test code looks like thi...
I've been trying for a while now to write a unit test for a UserViewControl in ASP.NET MVC. I'd like to get to code that looks something like this: [TestMethod] public void HaveControlToDisplayThings() { var listControl = new ControlUnderTest(); var viewData = new ViewDataDictionary<IList<string>>(this.repo.GetMeSomeData()); ...
I am new to jmock and trying to mock an HttpSession. I am getting: java.lang.AssertionError: unexpected invocation: httpServletRequest.getSession() no expectations specified: did you... - forget to start an expectation with a cardinality clause? - call a mocked method to specify the parameter of an expectation? the test method: @Tes...