unit-testing

Should failing tests make the continuous build fail?

If one has a project that has tests that are executed as part of the build procedure on a build machine, if a set tests fail, should the entire build fail? What are the things one should consider when answering that question? Does it matter which tests are failing? Background information that prompted this question: Currently I am w...

How to profile methods in dependent assemblies in a unit test instrumentation performance session?

I have a Visual Studio 2008 unit test project that depends on a dll project in the same solution. With this setup, I want to profile a single unit test with a Visual Studio performance session. Said test calls into methods located in the dll project and I want to see where the perf bottleneck is in that dll. So far so good. At first it ...

Comparing XMLs using XMLUnit RecursiveElementNameAndTextQualifier

Hi, I am trying to compare 2 XML files using XMLUnit 1.2. I am using the RecursiveElementNameAndTextQualifier() qualifier. When changing the order of some entities order in my XML, it causes XMLUnit to pass on some cases and fail on other cases. My XML file looks like this, and I'm comparing it to a similar copy with a simple locat...

Unit Testing my Email Service

How do I write a unit test for a method that use an external service like System.Net.Mail? Do I just check a return value to see if there were any errors sending the email and assume if there were none that it was sent successfully? ...

Getting Started with Unit Testing in C# with Visual Studio

I know Visual Studio offers some Unit Testing goodies. How do I use them, how do you use them? What should I know about unit testing (assume I know nothing). This question is similar but it does not address what Visual Studio can do, please do not mark this as a duplicate because of that. Posted as Community Wiki because I'm not trying ...

Reflection: walking a class for automated testing

I have classes that store data, and methods to go get data for individual loans. I have code that walks properties and pulls the data back, but according to the MSDN coding guidelines properties are just supposed to get data, not do anything. My properties actually move to a screen on a mainframe and scrape data. So when I am mousing ov...

Boolean Expressions in SQL Select list

I want to create a SQL Select to do a unit test in MS SQL Server 2005. The basic idea is this: select 'Test Name', foo = 'Result' from bar where baz = (some criteria) The idea being that, if the value of the "foo" column is "Result", then I'd get a value of true/1; if it isn't, I'd get false/0. Unfortunately, T-SQL doesn't like the ex...

Is it bad form to count on the order of your NUnit unit tests.

I have been creating Unit tests like crazy and find that I'm often having to set up something in one test that I just tore down in a previous test. Is it ever reasonable to create something (e.g. a database record) in one test (e.g. an Insertion test) and then use it for a later test (e.g. a Deletion test)? Or should each and every tes...

How do you test whether a model has a given method in Rails?

I would like to implement the method User.calculate_hashed_password. I'm trying to use the Shoulda testing library which works with Rails's built-in testing tools, so an answer related to Test::Unit would be just as good as one related to Shoulda (I think). I'm trying to figure out what I need to test and how I should test it. My initia...

What are some of the things to watch for (pitfalls) while using IOC container?

What are some of the things to watch for (pitfalls) while using IOC container? ...

Do you think Unit Tests are a good way to show your fellow programmers how to use an API?

Do you think Unit Tests are a good way to show your fellow programmers how to use an API? I was listening to the Stackoverflow Podcast this week and I now realize that unit testing is not appropriate in all situations (I.E. it can cost you time if you go for 100% code-coverage). I agree with this as I have suffered from the "OCD code c...

How can I do unit testing in Perl?

I have been doing some OO Perl programming and I was wondering: which is the best way to perform unit tests? So far I have been using the Test::Simple module to perform tests, but it feels insufficient for what I want. Can you point me to some nice modules for that? ...

How do I test a code generation tool?

I am currently developing a small project of mine that generates SQL calls in a dynamic way to be used by an other software. The SQL calls are not known beforehand and therefore I would like to be able to unit test the object that generates the SQL. Do you have a clue of how would be the best approach to do this? Bear in mind that ther...

Django: How to create a model dynamically just for testing

I have a Django app that requires a settings attribute in the form of: RELATED_MODELS = ('appname1.modelname1.attribute1', 'appname1.modelname2.attribute2', 'appname2.modelname3.attribute3', ...) Then hooks their post_save signal to update some other fixed model depending on the attributeN defined....

Unit testing XML Generation.

What unit testing strategies do people recommend for testing xml is being generated correctly. The my current tests seem abit primitive, something along the lines of: [Test] public void pseudo_test() { XmlDocument myDOC = new XmlDocument(); mydoc = _task.MyMethodToMakeXMLDoc(); Assert.AreEqual(myDoc.OuterXML(),"big string of ...

Best unit test tutorials for beginners

Most decent programmers know that unit testing is important, but may not know where to begin. For a long time I knew the benefits of unit testing, but could never seem to figure out where a good starting point was. Most articles I read on the subject dealt with the high level theoretical, rather than the down-and-dirty practical. I've...

Using unit tests as a "functionality contract"

Unit tests are often deployed with software releases to validate the install - i.e. do the install, run the tests and if they pass then the install is good. I'm about to embark on a project that will involve delivering prototype software library releases to customers. The unit tests will be delivered as part of each release and in addit...

How do you Unit Test an .EXE with 3rd party dll?

I'm still learning the dark arts of TDD and recently I've been trying to learn how to do TDD in VB6 and what I basically narrow down the list to was the free simplyvbunit and the most costly vbunit3. My application is an richtext editor with plenty of 3rd party dll and I was scouring high and low in Google to find how to do unit test t...

Writing standards for unit testing

I plan to introduce a set of standards for writing unit tests into my team. But what to include? These two posts (Unit test naming best practices and Best practices for file system dependencies in unit/integration tests) have given me some food for thought already. Other domains that should be covered in my standards should be how test...

Testing a test?

I primarily spend my time working on automated tests of win32 and .NET applications, which take about 30% of our time to write and 70% to maintain. We have been looking into methods of reducing the maintenance times, and have already moved to a reusable test library that covers most of the key components of our software. In addition we h...