unit-testing

Unit Testing: Self-contained tests vs code duplication (DRY)

Hi guys, I'm making my first steps with unit testing and am unsure about two paradigms which seem to contradict themselves on unit tests, which is: Every single unit test should be self-contained and not depend on others. Don't repeat yourself. To be more concrete, I've got an importer which I want to test. The Importer has a "Impor...

Debugging unit test cases in VS 2008

Hi all, I'm trying to debug some of my unit tests in Visual Studio 2008 and have noticed that breakpoints don't seem to be halting execution. I kind of assumed that it was as simple as setting a breakpoint and then doing "Test | Debug | Tests in current context" ... but this never actually hits the breakpoints that I've set. Am I doin...

Subsonic 3 Active Record Testing

Using the new built in testing for Active Record (set "Test" as the connection string) I've hit a problem performing an update. The code I'm testing pulls an existing object out of the database, makes some changes to it, and then saves it. public void SaveProduct(string productId) { var dbProduct = Model.Generated.Product.SingleOrDefa...

What is the ideal timeframe for testing code

I'm currently working on a critical monthly Accounts payable report. This report i just wrote will be the basis for my client in which how much is he going to pay to his vendors. So far i have spent about 5 hrs building automated tests and found zero errors so far. Do you think i am already spending too much time testing? What should be ...

Use of <mbunit> in NAnt fails

Hi Everyone, I got stuck up when I tried to run the Unit Test written using mbunit from NAnt. when I tried this lines of code in NAntbuilder. <mbunit report-types="Html;Xml;Text" report-filename-format="${test_results.file}" report-output-directory="${test_results.directory}" halt-on-failure="true" failonerror="tru...

Best unit testing framework for old school QNX ?

I'm working on an old variant of unix (qnx 4.x to be exact). I'm trying to shoe-horn in modern software methodologies atop 20+ year old technology. In short I need a unit testing framework for QNX. Keep in mind we've got a bare bones C compiler and that's pretty much it. Anyone got any suggestions on how I can unit test this beast? ...

iPhone - Retrieving Resources for logical unit tests

I've been following Apple's documentation on writing unit tests for the iPhone, and out of the box, the routine doesn't seem to work. I'm not sure I understand where the unit test is going to get the reference to the application delegate. My Dependencies are like the following: My_Program_target -> UnitTesting_target -> UnitTests_bundl...

Hamcrest's hasItems

Why does this not compile, oh, what to do? import static org.junit.Assert.assertThat; import static org.junit.matchers.JUnitMatchers.hasItems; ArrayList<Integer> actual = new ArrayList<Integer>(); ArrayList<Integer> expected = new ArrayList<Integer>(); actual.add(1); expected.add(2); assertThat(actual, hasItems(expected)); error copi...

Unit testing and checking private variable value

I am writing unit tests with C#, NUnit and Rhino Mocks. Here are the relevant parts of a class I am testing: public class ClassToBeTested { private IList<object> insertItems = new List<object>(); public bool OnSave(object entity, object id) { var auditable = entity as IAuditable; if (auditable != null) inser...

Is there a Scala unit test tool that integrates well with Maven?

My company is beginning to write some code using Scala. I've been moved onto this project, and am a big fan of TDD, so I would like to get a unit-testing framework in place. However, the build system we're using for this project is Maven, and that's not going to change, for a variety of reasons. I've looked at both ScalaTest and Scala...

Excel 2007 DataSource connection error in Visual Studio 2008 unit test

Hello, I am trying to use an Excel 2007 as a data source in my VS 2008 Test Project a unit test. Config file: <configuration> <configSections> <section name="microsoft.visualstudio.testtools" type="Microsoft.VisualStudio.TestTools.UnitTesting.TestConfigurationSection, Microsoft.VisualStudio.QualityTools.Un...

Unit testing an iPhone static library with XCode 3

I am writing a number of static libraries for the iPhone and wish also to have suites of unit tests. XCode 3 provides templates for both static libraries and unit tests but I am wondering how they should fit together in a static library project? In my static library project I have created a target for unit testing but expect to also cre...

How to test methods that may not always give correct answer

Imagine that you have an internally controlled list of vendors. Now imagine that you want to match unstructured strings against that list. Most will be easy to match, but some may be reasonably impossible. The algorithm will assign a confidence to each match, but a human needs to confirm all matches produced. How could this algorithm...

Is there such a thing as too much unit testing?

I tried looking through all the pages about unit tests and could not find this question. If this is a duplicate, please let me know and I will delete it. I was recently tasked to help implement unit testing at my company. I realized that I could unit test all the Oracle PL/SQL code, Java code, HTML, JavaScript, XML, XSLT, and more. Is...

Unit Testing Adding to Zip / Extracting from Zip

I have the following code for adding to/extracting from Zip. I'm trying to refactor this to make it test-ready. Can someone provide pointers on how I can accomplish this? Aside: I'm using Moq as my mock framework and MSTest as my Unit Testing tool private const long BufferSize = 4096; public static void ExtractZip(string zipFilename...

How do you add sample (dummy) data to your unit tests?

In bigger projects my unit tests usually require some "dummy" (sample) data to run with. Some default customers, users, etc. I was wondering how your setup looks like. How do you organize/maintain this data? How do you apply it to your unit tests (any automation tool)? Do you actually require test data or do you think it's useless? M...

double unit test reporting with hudson and maven

Hi, I have a maven2 project in hudson and when the cobertura reporting plugin runs, it causes the unit tests to show that they have run twice. I don't mind them running multiple times, but the trend graph shows twice as many tests as we actually are running. Is there a way to make sure the graph only shows them once? thanks, Jeff ...

Verify that either one method or the other was invoked in a unit test

Example: public bool Save(MyObj instance) { if (instance.IsNew) { this.repository.Create(instance); } else { this.repository.Update(instance); } } How do I create a test in Moq that verifies: that a property IsNew is being read that either Create() or Update() has been invoked ...

How to automate installer testing

I'm wondering if anyone has any best practices for automating the testing of installers on various machines with potentially different hardware / software profiles and by specifying various options to the installer. The idea would be that I could write "unit test like" code to set up a machine, run the installer, then test that certain ...

How do I Unit Test for relative performance?

Given that I don't know at deployment time what kinds of system my code will be running on, how do I write a Performance benchmark that uses the potential of a system as its yardstick. What I mean is that if a system is capable of running the piece of code 1000 times per second, I'd like the test to ensure that is comes under as close t...