unit-testing

If a project has 100% unit test coverage, are integration tests still needed?

If a project has 100% unit test coverage, are integration tests still needed? I have never worked on a project with 100% unit test coverage, but I'm wondering if your project obtains this (or in the 90%), was your experience that you still needed integration tests? (did you need less?) I ask because integration tests seem to suck. T...

If unit testing is so great, why aren't more companies doing it?

The first real software company that I worked at was all about the unit testing (NUnit). I don't know that we were real sticklers for it back then -- I have no idea what our code coverage was like and I was writing most of the unit tests. Since then I've run into some companies that do lots of testing, but it's chair testing: relies on a...

What kinds of unit tests pay off the most in business value?

My question assumes that folks already believe that unit tests of some sort are worthwhile and actually write them on their current projects. Let's also assume that unit tests for some parts of the code are not worth writing because they're testing trivial features. Examples are getters/setters, and/or things that a compiler/interpreter ...

How do I unit test a method containing an asynchronous call?

I have a method that contains an asynchronous call like this: public void MyMethod() { ... (new Action<string>(worker.DoWork)).BeginInvoke(myString, null, null); ... } I'm using Unity and creating mock objects is not a problem, but how can I test that DoWork is called without worrying about race conditions? A previous que...

How do you tell that your unit tests are correct?

I've only done minor unit testing at various points in my career. Whenever I start diving into it again, it always troubles me how to prove that my tests are correct. How can I tell that there isn't a bug in my unit test? Usually I end up running the app, proving it works, then using the unit test as a sort of regression test. What i...

I want to load all of the unit-tests in a tree, can it be done?

I have a heirarchical folder full of Python unit-tests. They are all importable ".py" files which define TestCase objects. This folder contains thousands of files in many nested subdirectories and was written by somebody else. I do not have permission to change it, I just have to run it. I want to generate a single TestSuite object whic...

Unit testing code that does date processing based on today's date

When code processes dates based on the current date, testing should cover edge cases such as leap years as well as the more frequent month and year boundaries. In our code we always get the current date deep down in our classes using DateTime.Now (.NET, in our case). How can you unit test such code? Is this where Dependency Injection ...

Spring beans redefinition in unit test environment

Hi all, we are using Spring for my application purposes, and Spring Testing framework for unit tests. We have a small problem though: the application code loads a Spring application context from a list of locations (xml files) in the classpath. But when we run our unit tests, we want some of the Spring beans to be mocks instead of full-...

Unit testing framework timeouts in Visual Studio 2008

I'm running some unit tests for a large VB.Net application I help maintain and am running into problems with tests timing out. The test run is set up so that there's no timeout limit on the overall test run, but a limit of 2 minutes per individual test. However, a couple of the tests take a lot longer than this to run, so we tried addi...

Detecting overwriting of ruby test methods

If you write a test class like class MyTest < Test::Unit::TestCase def setup end def test_1 flunk end def test_1 assert true end end the first test_1 is ignored. Although it looks like a stupid mistake, it can happen with copy and paste programming. Apart from running grep test test_me.rb | wc and comparin...

How to best do unit testing for a web application

I am writing a web application that is very complex in terms of UI and relies heavily on AJAX, DOM and image manipulations. Is there any standard practice (I don't want tools) which can be followed to reduce the bugs? ...

Standard .Net TDD Memory Test

Is it useful to write a standardised TDD [Test] method that would expose common memory issues ? The set of tests could be easily, quickly applied to a method and would red-fail 'classic' .NET memory issues but would green-pass the classic solutions. For example common memory issues could be : too much relocation by the garbage collec...

How to use the Unit test tool comes with VS2008 Pro to test a C++ proj?

Here's what i've done: i choose Test -> create new test -> wizard Then it asked me to enter a proj name. i did. then it told me to select a source proj to test, i chose my working proj... but... a warning dialog popped up saying : "Unknown virtual address 0" and refuse to continue. i tried rebuilding my source proj many times... no luc...

Failing NUnit test when running through CC.NET

The solution for this error has escaped me for several days now, and it is time to come here for help. The short version is, I have a unit test that fails on the build server but no other environment. The method I'm testing is an extension method for ILog in log4net. The purpose of this extension method is to make a debug log of the cur...

Does anyone know of a good Perl unit test generator?

Does anyone know of a good Perl unit test generator? ...

Odd problem unit testing internal classes with VS 2008

I'm starting a project which is broken up over multiple VS projects and I was planning on having separate testing projects for each of the projects, so I'd have a solution like this: Project1 Project1.Test Project2 Project2.Test There are some internal classes which I want to have tested. So I used Visual Studio 2008 (SP1) to generat...

which visual studio edition has this assembly?

i have a .proj file in which this reference is included, but i cannot find the a appriate assembly on my disk. Microsoft.VisualStudio.QualityTools.UnitTestFramework which visual studio edition does this assembly include, or is there another way to get this assembly? ...

how to setup private constructor?

how to setup the unit test if the constructor is private (.NET)? public class Class2 { private Class2() //private constructor { } public static Class2 getInstance() { if (x == null) x= new Class2(); return x; } } namespace TestUnit { [TestFixture] public class Class2Tester { private Class2 test; [SetUp()] pub...

Have you used Quickcheck in a real project

Quickcheck and its variants (even there is one in java), seems to be interesting. However, apart from academic interest, is it really useful in a real application testing (Eg. a GUI application or Client/Server or even take StackOverflow itself)? Any experiences you had with similar test generators is appreciated. ...

Agile Documentation Frameworks (NTestDox?)

I was reading this blog post: http://www.shakie.co.uk/ramblings/feature-driven-development-riding-the-waves-of-change/ and came across the part about TestDox: Direct quote (hence PHP): Take the following test case as an example class InvoiceTest extends PHPUnit_Framework_TestCase { public function testValueIsInitiallyZero() ...