473,396 Members | 2,121 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

NUnit question:

How does one control the order in which a sequence of tests are performed
using NUnit?

e.g.

[Test]
public void BTest()
{
}

[Test]
public void ATest()
{
}

When compiling it seems that the "ATest" is performed before the "BTest",
eventhough the "BTest" is declared first in the TestFixture.

I'm in a situation where the different test can be dependent on each other -
that's why.

/Claus
Nov 16 '05 #1
3 1142
Claus Konrad wrote:

How does one control the order in which a sequence of tests are performed
using NUnit?

e.g.

[Test]
public void BTest()
{
}

[Test]
public void ATest()
{
}

When compiling it seems that the "ATest" is performed before the "BTest",
eventhough the "BTest" is declared first in the TestFixture.

I'm in a situation where the different test can be dependent on each other -
that's why.

/Claus


I'm pretty sure that they are executed in alphabetical order (at least that is
what I've noticed in my unit test).

Regardless, I don't think that it is recommended that you base the effects of
one test on another. I'd recommend moving the the common code to [SetUp] or
explicitly calling the necessary predecessor functions. If you can't do that,
then I guess you need to name your tests in alphabetical execution order.
Nov 16 '05 #2
Tests are suppose to be autonomous. I would suggest refactoring your tests
so that they are not dependent on one another.

But, if you actually need then you could consider explicitly calling the
first test when the second test runs to make sure your state is as you need
it. This would not prevent the test from running a second time, that you
would then have to watch for.

"Claus Konrad" <cl***@whoknows.it> wrote in message
news:u$**************@TK2MSFTNGP12.phx.gbl...
How does one control the order in which a sequence of tests are performed
using NUnit?

e.g.

[Test]
public void BTest()
{
}

[Test]
public void ATest()
{
}

When compiling it seems that the "ATest" is performed before the "BTest",
eventhough the "BTest" is declared first in the TestFixture.

I'm in a situation where the different test can be dependent on each other - that's why.

/Claus

Nov 16 '05 #3
>
But, if you actually need then you could consider explicitly calling the
first test when the second test runs to make sure your state is as you need
it. This would not prevent the test from running a second time, that you
would then have to watch for.


We tried this in a large ish project, and it got quite confusing when
tests called by other tests started to fail. We moved to a combination
of [Setup] and refactored common functions.

When common functionality spanned test classes we moved common
functions to simple base classes (containning no tests).

It still wasn't perfect but it was simple to follow, which has to be
worth a few points.
Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: serge desmedt | last post by:
Hi, Where about to start using Unit Testing for dotNet. I have experimented with the NUnit framework and have the following question: According to the documentation of NUnit , using the...
2
by: d2d | last post by:
How are you doing there folks? I just have this newbie question about how to compile an NUnit test file from command line using "csc.exe" I installed NUnit 2.1 using *.msi file. I was...
7
by: Alvin Bruney | last post by:
I've a question on unit testing with NUnit. I'm sure I'm missing just a little thing here. Why doesn't NUnit allow me to test a routine with parameter in it like what i want to do is test ...
5
by: Naveen Mukkelli | last post by:
Hi all, How can we use "NUnit" in socket programming. I mean, I'm writing a server program which accepts connection requests from the clients. I want to test the number of clients whenever a...
2
by: Ray Cassick \(Home\) | last post by:
I have started using this on a regular basis and have a question regarding conditional compilation. I have all my test cases wrapped in an #if/#endif that checks to see if the build is debug or...
0
by: Ray Tayek | last post by:
hi, getting a: .\Stdafx.cpp : fatal error C1192: #using failed on 'i: nunit\samples\cpp-sample"' 'The filename, directory name, or volume label syntax is incorrect.' nunit is installed in...
6
by: Ray Tayek | last post by:
hi, i am preparing to teach a class in c++ and would like to intoduce some unit testing. i can make unit tests in c# using this dll and nant from the command line. i am using visual c++ 2005...
20
by: Parag | last post by:
Hi, I am trying to figure out best testing tool for my project. I have narrowed down my requirements to two tools NUNIT and VSTS unit. But I have used neither and I have to use only one of them....
2
by: JohnGoogle | last post by:
Hi, I'm a newbie so sorry if there is a simple answer to this! I'm using C# in Visual Studio Express at the moment. I've downloaded NUnit v 2.2.8 and can load and run the tests they supply...
1
by: Gonza | last post by:
Hi group, i'm trying to create tests for my solution, so i have a project with nunit tests. I'm using the data application block as my data access layer, and the problem i'm having is that when i...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.