nunit

ExpectedException in jUnit?

Is there an equivalent to NUnit's ExpectedException or Assert.Throws<> in jUnit? ...

Why not hit the database inside unit tests?

Hi I've read in blogs that the database should not be hit when the unit tests run. I understand the theory, however say i have complex store procedures that are part of a business domain operation. I want to write a set of unit tests for the code related to the business operation, however if i mock the database i have the feeling that im...

NUnit tests in a separate project, same solution

I have a solution containing my main project and a test project using NUnit. Everything compiles but when I run NUnit I get the exception below after the tests load, and the tests fail. I've added the main project as a reference, and I have $(ProjectDir)bin/Debug/$(TargetName)$(TargetExt) in the arguments for NUnit in the external tools ...

nunit resharper expected exception testing

I truly love NUnit's new(er) ability to test for expected exception testing, ie: var ex = Assert.Throws<SomeException>(()=>methodToThrowException("blah")); One minor issue I find is that to test some sort of operator overload or other assignment type functionality, the only way I can know how to do this is by giving the compiler a va...

MSBuild task for combining NUnit or MSTest XML results

I have a set of NUnit XML result files (produced by xUnit.NET via the NUnitXml parameter to the Xunit.Runner.MSBuild.xunit msbuild task pretty much as in http://stackoverflow.com/questions/517560/how-do-i-get-team-build-to-show-test-results-and-coverage-for-xunit-net-test-suit and http://jonnekats.wordpress.com/2009/05/07/integrate-xunit...

How do i write Test Classes using nUnit Framework?

Hi, How do i Assert to test a method that has no return value. For example: public void UpdateProfileVersion (ILimitedDataConnection connection, int effectiveUserID, int OrgID, int EntityTypeID) { OrgStoredProcedures.OrgGroupProfileUpdateData(connection, Convert.ToInt32(OrgGroupProfileStatus.History), OrgID, EntityType...

How to load my test data in C#?

Hi, I am struggling to find an easy way to load my test data in C#. In Java, I load a resource using the following code: ... public static InputStream loadResource(String resource) throws LoadException { InputStream is = TestUtils.class.getResourceAsStream(resource); if (is == null) { throw new LoadException("Error l...

How do I unit test an implementation detail like caching

So I have a class with a method as follows: public class SomeClass { ... private SomeDependency m_dependency; public int DoStuff() { int result = 0; ... int someValue = m_dependency.GrabValue(); ... return result; } } And I've decided that rather than to call m_dependency...

NUnit Test Run Order

Hi, By default nunit tests run alphabetically. Does anyone know of any way to set the execution order? Does an attribute exist for this? Any help would be greatly appreciated. Thanks Zaps ...

What advantages/disadvantages do MSTest and NUnit have compared to each other?

Since Microsoft created MSTest, I've been using it for unit testing. I never really used NUnit, and I just didn't like the need to have yet another tool installed on my dev box. I've only used the basic features of MSTest so far, and they have satisfied my needs, and I don't really know anything about NUnit. Could someone list out some ...

NUnit Assert.Equals What am I missing?

Assert.Equals() never calls Equals() operator == operator != Am I missing something? I have implemented IEquatable but still the methods are never being called while using nunit. if (objectA != objectB) Assert.Fail(); //doesnt fail if (!objectA.Equals(objectB)) Assert.Fail(); //doesnt fail Assert.AreEqual(objectA, objectB); //fail ...

CollectionAssert in jUnit?

Is there a jUnit parallel to NUnit's CollectionAssert? ...

nunit automatic test generator vs2005

Is there a good free plugin for generating a template for Nunit test for visual studio 2005? ...

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...

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...

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...

Rhino Mocks Calling instead of Recording in NUnit.

I am trying to write unit tests for a bit of code involving Events. Since I need to raise an event at will, I've decided to rely upon RhinoMocks to do so for me, and then make sure that the results of the events being raised are as expected (when they click a button, values should change in a predictable manner, in this example, the hei...

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...

Using automated unit test for black box integration test, how bad is that and what is better?

I have an API that can be implemented by various vendors. I can send and receive data and get different return codes with the API. What I want to do is be able to test the API and in an automated fashion and keep everything as clean as possible. Not really doing unit testing. This would be for use in a testing/QA setting. What I have d...

Automatically print/save NUnit XML output

I've setup some Nunit tests for validating my statistical formulas within my .net v2 application, for company records i need to have a printed copy of this output. Is anyone aware of any commands in NUnit to automatically print the XML to default printer? If printing isn't possible saving to a folder may work for us. thanks in advance...