unit-testing

Using Post-Build Event To Execute Unit Tests With MS Test in .NET 2.0+

I'm trying to setup a post-build event in .NET 3.5 that will run a suite of unit tests w/ MS test. I found this post that shows how to call a bat file using MbUnit but I'm wanting to see if anyone has done this type of thing w/ MS Test? If so, I would be interested in a sample of what the bat file would look like ...

Getting started in Unit Testing as a group in these economic times.

We have a group of a few developers and some business analysts. We as developers would like to start adding unit testing as part of our coding practices so that we can deliver maintainable and extensible code, especially since we will also be the ones supporting and enhancing the application in the future. But in this economic downturn w...

What are the advantages of self-testing code vs separated tests?

Personally, I've always put unit tests in a separate project just because that's how MSTest seems to be set up. But I'm reading Refactoring: Improving the Design of Existing Code by Martin Fowler and he seems to be advocating not only putting them in the same project, but also putting them in the same class as the method they're testing...

Good C# Unit testing book

Hi everyone, I'm interested in adding some tests to my code. I write primarily in C#, but I'm having difficulty finding examples for unit testing that aren't trivial (i.e. unit test a function to capitalize a string). Does anyone know of a good book that explains how to write unit tests for non-trivial examples in c#? I've seen the prag...

Testing IO.Stream interaction

I have a method in my business logic layer that accepts a stream, which in the GUI comes from a user uploading a file, and I am interested in which is an appropriate way to test that the method appropriately uses this stream to make decisions. public Sub Initialize(ByVal uploadStream As Stream) ''// Logic using uploadStream End Sub ...

Rails fixtures -- how do you set foreign keys?

I'm reading about Rails fixtures in this guide (thanks, trevorturk). It appears you define classes in a Yaml file and they're automatically loaded into the test DB -- cool. But if you want to specify that this recipe belongs to that cookbook (or whatever) how do you do that? Are you supposed to specify the values for cookbook.id and re...

How to write a functional test for a DBUS service written in Python?

(Title was: "How to write a unit test for a DBUS service written in Python?") I've started to write a DBUS service using dbus-python, but I'm having trouble writing a test case for it. Here is an example of the test I am trying to create. Notice that I have put a GLib event loop in the setUp(), this is where the problem hits: import u...

Limiting number of test run results in Visual Studio 2005

Hi, I have a 'suite' of VS2005 unit tests that attach a db as part of the initialization. Tests modify the db fairly substantially so need to revert it to a known state before each test run. I deploy the test db to the 'out' folder of each TestResult and attach it in the MyClassInitialize method. DB is fairly large so this uses up lo...

What would you include in a 10 min Grok talk on Unit Testing

Hi, I'm soon to do a 10min Grok talk on Unit Testing at my company. I've been trying it myself, and feel that it can certainly bring benefits to the company. We already do WebInject testing in our dedicated QA team, But I want to try and sell unit testing to the devs. So with only 10mins what would you cover and why? we're a Microsof...

Testing in ASP.net MVC Beta 1

I'm wring a unit test for a controller and here is my code. public void DocumentController_IndexMethod_ShouldReturn_Documents() { DocumentsController c = new DocumentsController(_repository); ViewResult result = (ViewResult)c.Index("1"); DocumentsController.DocumentsData data = (DocumentsController.Document...

Use Mockito to verify that nothing is called after a method

I'm using Mockito to write a unit test in Java, and I'd like to verify that a certain method is the last one called on an object. I'm doing something like this in the code under test: row.setSomething(value); row.setSomethingElse(anotherValue); row.editABunchMoreStuff(); row.saveToDatabase(); In my mock, I don't care about the order ...

Unit Testing XQuery

I've been working with a document repository using XQuery (via Java and .NET interfaces) and was wondering if anyone has any recommendations for unit testing XQuery modules? ...

Should I write unit test for everything?

Hi, I am wondering should I write unit test for everything. There are some classes is very difficult to write unit test. For example, I am writing some program for handling audio. The class for capturing audio from microphone, and class for play audio to speaker, how can I write unit test for those classes? I can't get output and input ...

NUnit reference binaries in other directory

Hi, I'm running the NUnit tests and everything is fine as long as the required dlls are in the same directory as tests. Otherwise I get the error "Could not load file or assembly". NUnit console doesn't seem to have any switch to include default path, nor it uses system PATH variable while looking for assemblies. The question is how to...

Places you can ask for quick code review?

Learning how to unit test in my own time though is providing me with further insight, I'd often would of liked to have someone there saying that I'm indeed going in the right direction with my tests. Doing this by myself (and being the only developer at my company actively looking into unit testing) I get no privilege nor do I have cont...

How to use web.config when unit testing an asp .net application

I am starting out with unit testing, I have a method that uses the web.config for a connection string. I was hoping to be able to use [DeploymentItem("web.config")] to get the web config file, this still leaves me with null reference exceptions (that'd be what I write my next test for). How do I use the config file included with the...

Two test projects in one solution app.config problem (Visual Studio 2008 Professional)

I have 2 projects each one with its own unit test project, and one app.config for each project+test project pair. The tests do not fail if I run only one each time. But if use "Run all tests in solution" all tests will use just one of the app.config's, and it will be the wrong one for all tests in one of these test projects. How do I ru...

How do I ensure that only one of a certain category of job runs at once in Hudson?

I use Hudson to automate the testing of a very large important product. I want to have my testing-hosts able to run as many concurrent builds as they will theoretically support with the exception of excel-tests which must only run one per machine at any time. Any number of non-excel tests can run concurrently, however at most one excel t...

How to make sure developers are unit testing their code

How can you make sure that all developers on your team are unit testing their code? Code coverage metrics are the only way I can think of to objectively measure this. Is there another way? (Of course if you're really following TDD then this shouldn't be an issue. But let's just suppose you've got some developers that don't quite "get" T...

What do you test with your unit tests?

TDD is something that seems to be on everybody's lips these days, and I have tried some on my own but I don't think I'm getting the idea. I am getting a grip on how to write a unit test, but I don't understand exactly what my unit tests should test. If I have an action method that returns a list of data, what should I verify? Only that...