unit-testing

Unittesting methods that contain using statements

I am wondering if Unittesting and using statements can really go hand in hand as there is no way to mock the disposable object instantiated in the using statement. How would I be able to effectively unittest a method containing the following using statement? public void MyMethod() { using(MyDisposableClass disp = new MyDisposableCla...

RhinoMock test mock interface void functions?

I'm new to RhinoMock's just been doing state unit testing up till now. How do you test void functions? Getting the following complie error when setting up expectation, Expression does not produce a value Basically I want to test that a certain mock's method is called a certain amount of times. Cheers ...

Unit testing with Spring Security

My company has been evaluating Spring MVC to determine if we should use it in one of our next projects. So far I love what I've seen, and right now I'm taking a look at the Spring Security module to determine if it's something we can/should use. Our security requirements are pretty basic; a user just needs to be able to provide a usern...

Unit testing Event Handlers in SharePoint?

Is it even possible? So far, I found that we can buy TypeMock to mock the SharePoint objects and then use any free Mocking framework (Moq?) to do the rest of the job. What do you think? It seams that without TypeMock, it's impossible to do unit test within SharePoint. To properly test our events, we need to give the event a SPItemEve...

Python - doctest vs. unittest

I'm trying to get started with unit testing in Python and I was wondering if someone could inform me of the advantages and disadvantages of doctest and unittest. What conditions would you use each for? ...

Does TDD apply well when developing an UI?

What are your opinions and experiences regarding using TDD when developing an user interface? I have been pondering about this question for some time now and just can't reach a final decision. We are about to start a Silverlight project, and I checked out the Microsoft Silverlight Unit Test Framework with TDD in mind, but I am not sure ...

Unit testing a method that calls another method

What is the best way to unit test a method that calls into multiple methods, for example: modify(string value) { if(value.Length > 5) replaceit(value); else changeit(value); } This pseudo code has a modify method that (currently) calls either replaceit() or changeit(). I have already wrote tests for replaceit and changeit, ...

Getting PartCover to work

I want to try PartCover for code coverage. I'm running Visual Studio 2008 Professional with MSTest. The Professional Edition does not include the Team Testing tools, like Code Coverage. So, I'm trying PartCover, but I can't get it to work. In the PartCover.Browser I've selected the MSTest executable, I've pointed the working arguments t...

Why does this unit test fail when testing DateTime equality?

Using NUnit 2.2 on .NET 3.5, the following test fails when using DateTime.Equals. Why? [TestFixture] public class AttributeValueModelTest { public class HasDate { public DateTime? DateValue { get { DateTime value; return DateTime.TryParse(ObjectValue.ToStrin...

How can I detect if a program is running from within valgrind?

Is there a way to identify at run-time of an executable is being run from within valgrind? I have a set of C++ unit tests, and one of them expects std::vector::reserve to throw std::bad_alloc. When I run this under valgrind, it bails out completely, preventing me from testing for both memory leaks (using valgrind) and behavior (expecti...

How can I unit test my ASP.NET MVC controller that uses FormsAuthentication?

I'm working with a ASP.NET MVC solution in a test driven manner and I want to login a user to my application using forms authentication. The code I would like to end up with in the controller looks something like this: FormsAuthentication.SetAuthCookie(userName, false); My question is how do I write a test to justify this code? Is th...

How to organize python test in a way that I can run all tests in a single command?

Currently my code is organized in the following tree structure: src/ module1.py module2.py test_module1.py test_module2.py subpackage1/ __init__.py moduleA.py moduleB.py test_moduleA.py test_moduleB.py Where the module*.py files contains the source code and the test_module*.p...

How to deal with long running Unit Tests?

I've got about 100 unit tests and with a coverage of %20, which I'm trying to increase the coverage and also this is a project in development so keep adding new tests. Currently running my tests after every build is not feasible they takes about 2 moments. Test Includes: File read from the test folders (data-driven style to simula...

UnitTesting on iPhone doesn't build

I am trying to perform some unit testing on the iphone but for some reason I cannot get it to build the executable I have downloaded TestMyApp from the Standford lecture slides and that compiles and runs perfectly. I have created a test project and even gone as far as to use the test code from the Stanford sample but for some reason dep...

YAGNI - The Agile practice that must not be named?

As I've increasingly absorbed Agile thinking into the way I work, yagni ("you aren't going to need it") seems to become more and more important. It seems to me to be one of the most effective rules for filtering out misguided priorities and deciding what not to work on next. Yet yagni seems to be a concept that is barely whispered about...

Unittesting methods that contain Filesystem calls

I have a method I want to unittest that has filesystem calls in it and am wondering how to go about it. I have looked at http://stackoverflow.com/questions/129036/unit-testing-code-with-a-file-system-dependency but it does not answer my question. The method I am testing looks something like this (c#) public void Process(string input) {...

Should I mix my UnitTests and my Integration tests in the same project?

I am using NUnit to test my c# code and have so far been keeping unittests (fast running ones) and integration tests (longer running) seperate and in separate project files. I use nunit for doing both the unittests and the integration tests. I just noticed the category attribute http://www.nunit.org/index.php?p=category&r=2.2 that nu...

How to unit test C# Web Service with Visual Studio 2008

How are you supposed to unit test a web service in C# with Visual Studio 2008? When I generate a unit test it adds an actual reference to the web service class instead of a web reference. It sets the attributes specified in: http://msdn.microsoft.com/en-us/library/ms243399(VS.80).aspx#TestingWebServiceLocally Yet, it will complete wi...

Unit Testing Application_Start

I am looking for any kind of information (prefer Moq) on how to unit test the Application_Start method in Global.asax. I am using ASP.NET MVC and trying to get to that elusive 100% code coverage! The fact that I'm using MVC is not the point. And saying that not testing Start is not necessary isn't really the answer either. What if I ...

Can VS2008 Testrunner run MbUnit tests or not?

Ok, so I keep seeing how VS2008 has this nice unit test display and I can see people running NUnit tests within it on Dimecasts.net and this article seems to imply that MbUnit v3 should have support for using visual studio's test runner. And yet I can't get it to recognize my tests. Has anyone else been able to get Visual Studio to run...