I noticed some unit tests, like in the spring framework where you setup the object and the test but don't explicitly use the assert methods.
Essentially, you have an exception or not.
Is this unit testing? Is this something to avoid?
For example, here are some tests from the Spring framework. No assert clauses, just a test.
public v...
I'm trying to follow TDD (i'm newbee) during development of Service class which builds tasks passed by Service clients. The built objects are then passed to other systems. In other words this service takes tasks but returns nothing as a result - it passes built tasks to other Services.
So I'm wondering how can I write test for it because...
I cannot find a specific feature-by-feature comparison of Moq and Rhino. All the questions are "which do you like better and why", or "here's how you do a simple mock in rhino and how it's done in moq".
I cannot find a deep comparison anywhere. I'm aware of the syntax differences, I'm not looking for answers about that. I am looking ...
In .net, unlike in Java, methods are not virtual by default. In order to use most mock object frameworks, you either have to mark the methods that you want to use on your mock as virtual on the `real' object, or you have to have an interface that you can mock that the class under test will accept in lieu of the implementation.
It seems...
Consider the following interface:
public interface IMyCallback
{
void SomeEvent(int someArg);
}
which is the contract for a WCF callback that will be receiving "events" from a WCF service. My implementation for this interface looks like this
public class MyCallback : IMyCallback
{
void IMyCallback.SomeEvent(int someArg)
{
O...
I'm a little confused as to the purpose of the ExpectConstructor() method on the Mock class in TypeMock 3.5.
I would have thought that calling ExpectConstructor would cause the MockManager to fail upon Verify() if the constructor is not called, i.e. if an instance of the mocked type is not instantiated.
However, calling ExpectConstruc...
I have used Rhino.Mocks extensively currently writing some tests in Java using EasyMocks. However I was unable to pull out a LastCall.IgnoreArguments() Rhino.Mocks equivalent in EasyMocks.
How do I use Easy Mocks to return a value irrespective of the arguments in the method.
For example:
public interface ISoothSayer {
String SayS...
I'm using the entity framework to access my database and I want to mock the database context inside my unit tests so that I can test my middle tier classes free of their dependency on real data. I know that I'm not the first to ask about this (Mocking an Entity Framework Model), but after some googling I have an instinct that it might be...
Hi,
I am trying to set up some unit tests for an existing c++ project.
Here's the setup:
I have chosen Google Mock, which includes Google Test. I have added another project (called Tests) to the Visual Studio Solution. The units to test are in another project called Main. The plan is to add each cpp file that I want to test to the Tes...
Ideally, and you will think I am crazy, I can code some basic logic into a bash or korn script and open that functionality up to clients hitting them. There is a lot of plumbing involved in web services and I was wondering what tools and techniques more experienced developers have been using to prototype systems where a backend webservi...
How do you decide what to choose:
use mock objects for a test OR
create a test object/ object graph using an IoC framework and run test on that data
...
Hi
I'm using TypeMock Isolater to mock up some objects for some unit tests - attempting to use the AAA api (so the Isolate calls).
I have a straightforward singleton class where you call a static GetInstance(), which then returns an instance of the class. I thought it would be a simple matter of mocking that up, but I'm running into a ...
I'm trying to mock a data repository object but after setting an expectation on my MockRepository, it returns null every time. My code is as follows:
[Test]
public void GetById_NotNull()
{
Person expectedPerson = new Person() { Id = 1, Name="Jon"};
MockRepository MockRepository = new MockRepository();
...
I just switched to Moq and have run into a problem. I'm testing a method that creates a new instance of a business object, sets the properties of the object from user input values and calls a method (SaveCustomerContact ) to save the new object. The business object is passed as a ref argument because it goes through a remoting layer. ...
Dear gurus,
I am taking my first steps with MsTest and Moq and would like to unit test a Linq2SQL repository class. The problem is that I do not want the unit tests to permantly modify my development database.
Which would be the best approach for this scenario?
Let each test operate on my real development database, but make sure eac...
Hi!
I'm trying to grasp test driven development, and I'm wondering if those unit tests is fine. I have a interface which looks like this:
public interface IEntryRepository
{
IEnumerable<Entry> FetchAll();
Entry Fetch(int id);
void Add(Entry entry);
void Delete(Entry entry);
}
And then this class which implements that ...
For some reason I can't find one, but someone must have already created a .NET IO library wrapper. I want to be able to mock calls to File.Exists etc, and the static methods builtin don't lend well to this.
...
Hi all,
I am currently writing a wrapper library in C# that wraps a COM object that has a very small and painful to use API and am having a bit of problem with clutter.
This is the first project that I have used TDD and mocking on, so sorry if this isn't really a big problem. I gave a copy of my library to one of my work mates and t...
In my attempt to mock an object in Groovy using the mock.interceptor package:
def mock = new MockFor(TheClass);
mock.demand.theMethod{ "return" }
mock.use {
def underTest = new TheClass()
println underTest.theMethod()
}
The problem I have is when creating TheClass() in the use{ block, it uses the actual constructor which, in t...
Hi there,
I have a couple of ActionMethods that queries the Controller.User for its role like this
Boolean isAdmin = User.IsInRole("admin");
acting conveniently on that condition.
I'm starting to make tests for these methods with code like this
[TestMethod]
public void HomeController_Index_Should_Return_Non_Null_ViewP...