unit-testing

Unit Testing Frameworks - What are the key features

I've read a lot about the available .NET unit testing frameworks. What is not clear to me is what are the key features that differentiate the available frameworks. What are the must-have features that you look for when evaluating unit testing frameworks? ...

How do I unit test code that uses a Fluent interface?

I've created a few small fluent interfaces through method chaining. They typically call a number of Repositories that fetch data from webservices / databases. How should I go about unit testing methods that use the fluent interface? Public IEnumberable<Computer> FindComputers(string serialNumber) { return Computers.FindBySerialNu...

Spawning a separate process from within a unit test

I have some unit tests (yes, perhaps more integration-ey tests !) that I would like to spin up another jvm, and then run the test code from that "other" JVM (and wait for it to finish, collecting the results). Am interested if there is an easy/reliable way of doing that with junit (eg inherit the classpath of what is needed etc...) Any...

Dependency injection with a static logger, static helper class

Hi I have a static class which calls a static Logger class, e.g static class DoesStuffStatic { public static void DoStuff() { try { //something } catch(Exception e) { //do stuff; Logger.Log(e); } } } static class Logger { public static void Log(Exception e) { //do stuff here ...

Run all tests in a source tree, not a package

My unit tests are in a separate directory tree from my integration tests, but with the same package structure. My integration tests need external resources (e.g. a server) to be available, but my unit tests are properly independent of each other and the environment. In IntelliJ-IDEA (v7) I have defined a JUnit Run/Debug Configuration to...

Visual Studio .NET - MbUnit tests using Gallio Integration - issues with multiple asserts

I am using gallio to integrate mbunit's test runner with the mstest test runner in visual studio. it works VERY well - except when I am running a test with multiple assert statements. The test will either pass or fail based on the FIRST assert statement. I know a lot of people are against multiple asserts, but they are unavoidable in cas...

Ruby: TypeError: nil is not a symbol

I'm following this tutorial I'm focusing on the testing portion. I'm trying to test the following snippet: def test_disallowed_passwords u = User.new ...{some more testing code} assert !u.save <<<<<<This is line 27 The u. save should fail in this case. When I run the test, I get the following: ...

What to do when a new feature causes existing unit tests to become invalid?

I'm building a new application and trying to adhere to "test-first" development as faithfully as I can. I'm finding myself in situations where I need to implement/change a feature that has an effect of invalidating a number of existing unit tests. How should I be dealing with this? As I see it, there are 3 options: Update or remove all...

How to write unit test for ASP.NET MVC using VB.NET

Hi, Can you help with the problem which i'm currently facing? We've created ASP.NET MVC application with "Out Proc" seesion state managment. We are using strong type session in our control class. Here sample code FYR.. Public Class CustomerController Inherits TxnProcess TxnProcess -- this class extended by another class which is...

[grails] how to create dummy data for unit test ?

Hi, I need to insert dummy data on test environtment so that I can run unit test on it but I don't know how to declare it on BootStrap (just for testing, not for all environtment) can you help me ? thank you in advance ...

Error while creating tests in Visual Studio

When I try to generate a unit test for the following method (in a public static class) private static string[] GetFields(string line, char sep) { char[] totrim = { '"', ' ' }; return line.Split(sep).Select(col => col.Trim(totrim)).ToArray(); } The Tests output says: While trying to generate your tests, the following errors oc...

How do I start unit testing?

I know that unit testing is desirable, and I am interested in doing unit testing. The only problem is I have no idea how, or even where to start really. So my question is: How do I learn about and start unit testing? Specifically I frequently write Java code in NetBeans and C# code in Visual Studio and am interested in what tools to u...

State/Interaction testing and confusion on mixing (or abusing) them

Hello, I think understand the definition of State / Interaction based testing (read the Fowler thing, etc). I found that I started state based but have been doing more interaction based and I'm getting a bit confused on how to test certain things. I have a controller in MVC and an action calls a service to deny a package: public Acti...

Deploying a big test disguised as a program

If someone has created a small diagnostic, internal web app that uses (unit) tests as its logic, is there ever a valid reason to do that? Keep in mind that Nunit has to be deployed as well where ever this website goes. I'm of the view that programs should contain their own logic and possibly reusable parts (if available) but not wrap t...

Example invalid utf8 string?

I'm testing how some of my code handles bad data, and I need a few series of bytes that are invalid utf8. Can you post some, and ideally, an explanation of why they are bad/where you got them? Thanks! ...

Is it a bad practice to reference System.Windows.Form in your Unit Test project?

I have a class that I want to test the DialogResult value for. To get that type I need to add a reference to System.Windows.Forms. Is it bad practice to have this included in a test project? ...

Unit Testing and Code Coverage Frameworks for .Net?

I am about to start a new project and am looking around for both a unit testing framework and some sort of code coverage profiler. I've used the unit test framework in Visual Studio Pro in the past but I've never used a coverage framework. Does anyone have views on the best unit testing and code coverage frameworks around at the moment?...

How do you test an extension method on an Interface which calls another method in that Interface with a mock created by Rhino Mocks?

I'm testing an extension method on an interface 'ISomeInterface'. The extension method actually calls to another method in the interface. How do I set up a mock and the appropriate expectations (i want to set the expectation that 'SomeMethod', which is an defined method in the interface with a different signature then this extension met...

Is there any info on NHibernate code coverage (by its test suite)?

Just curious. Tried to google this, but found nothing. I remember earlier there was some information related to this, but now I can't find anything at all. So... I'd appreciate any help ;) ...

MSBuild: build results shows 'no code coverage' while importing test-result does

I have a strange problem, my MSBuild runs tests, code-coverage and publishing fine (part of the build.txt shown): Results Top Level Tests ------- --------------- Passed BuildTestProject.UnitTest1.TestMethod1 Passed BuildTestProject.UnitTest1.TestMethod2 2/2 test(s...