unit-testing

What is the correct way to implement the NUnit 2.5 Constraint.Write*() methods?

Hello: I'm planning to implement my own set of constraints, and am having some difficulty understanding how to implement the following methods of the Constraint class. public abstract class Constraint { public abstract void WriteDescriptionTo( MessageWriter writer ); public virtual void WriteMessageTo( MessageWriter writer ); ...

TestDriven.Net Only Running One Test Fixture In File

I'm using NUnit (but have also tried this with VS testing) and I'm having a problem getting TestDriven.Net to recognize and run different test fixtures in a single .cs file. I'm trying to do a little BDD style testing. So what I have in one file is something like this: [TestFixture] public class when_view_is_ready : AAA { // setup,...

VS 2010 unit test and unsigned type

I am converting my unit tests from NUnit to the VisualStudio 2010 unit test framework. This test fails with the message "Assert.AreEqual failed. Expected:<System.UInt16[]>. Actual:<System.UInt16[]>." what's actually very strange. This test was running successfully with NUnit. Any ideas why the types are supposed to be different? [TestMe...

Is there any point Unit testing serialization?

I have a class that serializes a set of objects (using XML serialization) that I want to unit test. My problem is it feels like I will be testing the .NET implementation of XML serialization, instead of anything useful. I also have a slight chicken and egg scenario where in order to test the Reader, I will need a file produced by the Wr...

Why do my OCUnit tests fail with "code 138"?

I'm currently trying to learn objective-c using XCode 3.1. I've been working on a small program and decided to add unit testing to it. I followed the steps on the Apple Developer page - Automated Unit Testing with Xcode 3 and Objective-C. When I added my first test, it worked fine when the tests failed, but when I corrected the tests...

What code don't you test?

Possible Duplicate: How deep are your unit tests? Ok, so it's common wisdom that it's impractical (and maybe not even preferable) to get 100% test coverage. In my experience, there's some code that's simply more trouble to test than it is practical to do so. I've kind of developed an intuition about this. But my team is sort ...

SpringJUnit4ClassRunner tests -- work from ant, not from IDE

I have some tests that load up some Spring context files. When I run the tests from my ant target they work as expected. When I run them from IntelliJ I get a NotWritablePropertyException. I initially figured different classpaths, but the only differences are for IntelliJ's test runner. Caused by: org.springframework.beans.NotWritablePr...

MSTEST PrincipalPermission

How do you unit test code decorated with the PrincipalPermission attribute? For example, this works: class Program { static void Main(string[] args) { AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal); var c = new MyClass(); } } [PrincipalPermission(SecurityAction.Demand, Role =...

How can I mock out a service using local data in Flex 3?

I am writing a small flex application that will, eventually, call PHP services to perform its work. In the meantime, however, I would like to have it use local data in XML form to allow me to develop the Flex part independently of the data service. What is the best way to do this? I want to emulate a service like this: public class S...

Mocking and DetachedCriteria in unit tests

How would you test the following code? public IList<T> Find(DetachedCriteria criteria) { return criteria.GetExecutableCriteria(session).List<T>(); } I would like to mock NH implementation (like setting mocks for ISession, ISessionFactory etc.) but I am having trouble with this one. ...

How to unit-test an MVC controller action which depends on authentification in c#?

I'd like to write (in c#) a unit-test for an MVC controller action which might return one view or the other, depending on whether the request is authenticated. How can this be done? Thanks in advance. ...

Using the WPF Dispatcher in unit tests

I'm having trouble getting the Dispatcher to run a delegate I'm passing to it when unit testing. Everything works fine when I'm running the program, but, during a unit test the following code will not run: this.Dispatcher.BeginInvoke(new ThreadStart(delegate { this.Users.Clear(); foreach (User user in e.Results) { t...

C#, C++/cli: How do you unit test a component that can only be loaded once per process

Hi, I'm currently implementing a .NET wrapper for a Java library by using JNI to start the JavaVM and interacting with Java classes. To be on the save side, I'd like to have unit tests for my code. The Problem I'm facing now is, you only can start the Java VM once per process. There is no possibility to unload the JVM. This makes it ...

Unit Testing Database Driven .NET Applications

What is the best way to unit test heavily database dependant .NET middleware? E.g. a process which reads data from multiple databases, manipulates it, and then combines and writes it to other databases? Should the databases be filled with static data which is somehow reset on each unit test run? Should the whole SQL Server access be som...

Which testing-framework for Javascript supports Testing without a browser?

For Javascript some testing-frameworks exist, like JSUnit or js-test-driver. They are fine, but they run the tests in a browser. That's fine, especially to verify your webapp is running in different browsers. But on out continuous-integration-server no window-system (and no browser) is installed. So is there a way to run the tests withou...

Why are my DBUnit tests consuming so much memory?

I've got a hibernate-based application which uses DBUnit for unit testing. We have an XML test database, which gets loaded up with dummy data in the setUp() of each test and deleted during the tearDown(). The problem is that I can no longer run the entire suite in an IDE (in this case, Intellij), because after about 300 tests, the heap...

How much testing is enough?

I recently spent about 70% of the time coding a feature writing integration tests. At one point, I was thinking “Damn, all this hard work testing it, I know I don’t have bugs here, why do I work so hard on this? Let’s just skim on the tests and finish it already…” Five minutes later a test fails. Detailed inspection shows it’s an import...

Building a life-critical System using Agile

Looking at the general trend of comments in my question about Building an Aircraft using Agile, the biggest problem other than cost appears to be safety. Do people feel that it is not possible to build a safe system (or prove it is safe) using agile? Doesn’t all the iterative testing mitigate this? Is it likely that a piece of software...

Resharper running all tests when only a single one is selected

I'm using Resharper 4.5 with Visual Studio 2008 and MBUnit testing, and there seems to be something odd with using ReSharpher to run the tests. On the side there are the icons beside the class each test method with the options Run and Debug. When I select Run it just shows me the results of the single test. However I noticed that the te...

Data-driven unit testing - Problem with CSV encoding?

Hi, I have the following CSV file that is used in my data-driven unit test: File;expected Resources.resx;default Resources.de.resx;de AttachmentDetail.ascx.it.resx;it SomeOtherFile.rm-CH.resx;rm-CH "File" and "expected" are the header. But if I want to get the "File"-column in the code like TestContext.DataRow["File"].ToString(); ...