unit-testing

Running VSTS tests without mstest.exe

From reasons I won't get into, all our unit tests are using the VSTS test framework. I now want to create an MSBuild script that runs the tests, but I don't want to use mstest.exe from various reasons (it's slower, requires Visual Studio installation everywhere, I need to maintain testrunconfig, etc.) I've seen that TestDriven.net and T...

MockEJB - JUnit Mockito - cannot rebind a mock EJB on second unit test

Hi I have a question related to MockEJB. I need to write unit tests to test a code that is calling a EJB. I use Mockito to write a mock for the EJB, and MockEJB to simulate the JNDI context. My tests look like this : @Test public void test1() throws Exception { // create a mock instance NetworkManager aMockManager = createMockNet...

How do I get ddsteps to insert Date & Time values in its test data sets?

Currently I am using DDsteps as a datadriven testing framework for my unit tests. It works quite well, except when inserting DateTime data into the database. Example data input row (stored in excel): APS_ID99${my.unique_four_digits} APS_LOGIN_DT3/21/2007 8:52 DDsteps will generate this SQL to load the date time field: insert...

Unit testing with an input file

All: I have a unit test that is testing functionality that requires an input file. This test was built using VS 2008's built-in unit testing feature. My problem is that the file needs to be discoverable by the unit test. However, when the test runs, it runs from a temporary "output" directory under the test results folder. It can't fi...

How do I write useful unit tests for a mostly service-oriented app?

I've used unit tests successfully for a while, but I'm beginning to think they're only useful for classes/methods that actually perform a fair amount of logic - parsers, doing math, complex business logic - all good candidates for testing, no question. I'm really struggling to figure out how to use testing for another class of objects: t...

Is there any way to identify if it is a test or not (.NET)?

I want that my application catches the exceptions and e-mail them when running in production, but when I am running my MSTest unit tests I want it to throw the exceptions, so I can debug. My current code always e-mails the exceptions. There is any way to know if the current process was invoked by the unit tests? One way I can think is t...

Using the aspnet_compiler.exe to compile .Net Web Apps

I have code in the top layer of my .Net web application that I'd like to unit test, but when my build server compiles the project using the aspnet_compiler.exe, it makes a .dll file that is not at all usable by another project, i.e. an NUnit test project. (This is true of ASP .Net web applications and of ASP .Net MVC applications.) Am ...

Categorizing MsTest Cases

I'm looking for the easiest way to categorize my tests so I can run them separately. My organization would be something like the following Units Tests Integrations Tests Systems Test The reasoning for this is all our testing hasn't evolved to be completely automated yet. Most of our unit tests are completely automated, while integ...

Does OCUnit allow application tests to be run on the iPhone Simulator?

Apple's "iPhone Development Guide" suggests on page 62 that "Because application tests run only on a device, you can also use these tests to perform hardware testing...". I'd like to run my OCUnit test cases in the simulator as well -- but haven't figured out how to do that. Is it possible? Or do I have to use Google's toolkit instead? ...

How to run all JUnit test cases from NetBeans?

Hi, I have created several files with unit tests on existing classes in NetBeans project. I used menu "File/New file/JUnit/Test for Existing Class" to create test files. I can run one file with unit tests by right click on it and select "Run File". But I want to run all files with unit tests. How can I achieve this in the simplest way...

Test Suite for a Linked List Implementation? (and/or other data structures)

For fun, I'm going to write my own implementations of common data structures like Linked List or Binary Sorted Tree. Are there any good test suites that already exist that I can use to make sure they are fully living up to their contracts? (It probably wouldn't be that hard to test them myself, but if it's already been done I don't want...

Asynchronous Errors in Actionscript: Exceptions? ErrorEvents?

So I have two classes: IOPin & Node A Node has a set of IOPins. To support loose coupling, and separation of concerns, I don't want the IOPins to have to know anything about Node. The Node should deal with adding/removing IOPins and should also deal with any error checking logic associated with this. This causes an issue when I want ...

Spring3/Hibernate3/TestNG: some tests give LazyInitializationException, some don't

Dear Sirs, The preface: I'm struggeling with LazyInitializationException in my Unit Tests, and I have a really hard time getting my head around it, as you can see from my questions Database Sessions in Spring, TestNG and Spring 3 and LazyInitializationException while unit-testing Hibernate entity classes for use in Spring, using TestNG...

Code Contract, Interfaces And Mocking

Hi all! I have a code contract on some interface IImageRepository: [ContractClassFor(typeof(IImageRepository))] sealed class IImageRepositoryContract : IImageRepository { IImage IImageRepository.GetById(int imageId) { Contract.Requires(imageId > 0); return default(IImage); } } I want to test code contract...

Problem mocking events attached to abstract class through constructor of other object

i have an abstract class and im trying to mock out events being attached to it using Rhino Mocks. Here a bit of the abstract class public abstract class Download { public virtual event EventHandler<DownloadProgressEventArgs> DownloadProgress_Changed; protected virtual void OnDownloadProgressChanged(DownloadProgressEventargs e) ...

Unit testing with ServiceLocator

I am doing a unit test on a class that uses the unity dependency injection framework. This returns null: ServiceLocator.Current.GetInstance(); How can I get it to return a mock object or just the object itself? ...

Python - Twisted and Unit Tests

I'm writing unit tests for a portion of an application that runs as an HTTP server. The approach I have been trying to take is to import the module that contains the HTTP server, start it. Then, the unit tests will use urllib2 to connect, send data, and check the response. Our HTTP server is using Twisted. One problem here is that I'...

Pros and Cons of unit testing with t#

I've recently stumbled upon T#. It seems a nice concept but I'm wondering if it's worth switching from nUnit to this? I love the pros but hate the cons so I'm still undecided Pros: specialized language for unit testing (keywords) relative assertions compile time warnings focus on test intentions Cons: lack of (integrated) tool sup...

Python Singletons - How do you get rid of (__del__) them in your testbench?

Hi SO's, Many thanks for the advice you have given me thus far. Using testbenches is something this forum has really shown me the light on and for that I am appreciative. My problem is that I am playing with a singleton and normally I won't del it, but in a testbench I will need to. So can anyone show me how to del the thing? I've s...

How can I mock %ENV in Perl tests?

I'm trying to retrofit some tests using Test::More to legacy code and I've bumped into a bit of a snag. I don't seem to be able to set %ENV in the test module. The called function definitely uses this variable so %ENV doesn't seem to be carried across to the test object. #!/usr/bin/perl use strict; use warnings; use Test::More qw(no_pl...