473,585 Members | 2,657 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

EXCLUDE nunit from production release

It is great to have an automated testing during development.

BUT,

How can I build the production release without nunit being included?

THX.

John
p.s. I posted this in nunit group but seems there are not much activity
there.

Jun 21 '06 #1
9 2348
Put your tests in a seperate test assembly.
Q. John Chen wrote:
It is great to have an automated testing during development.

BUT,

How can I build the production release without nunit being included?

THX.

John
p.s. I posted this in nunit group but seems there are not much activity
there.


Jun 21 '06 #2
I also need to test "internal" classes.

Jun 21 '06 #3
I would still put the tests in a separate assembly, and use reflection
to create instances and call methods/properties, etc, etc that you need.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Q. John Chen" <qj****@email.c om> wrote in message
news:11******** **************@ g10g2000cwb.goo glegroups.com.. .
I also need to test "internal" classes.

Jun 21 '06 #4
On 21 Jun 2006 07:38:52 -0700, "Q. John Chen" <qj****@email.c om>
wrote:
It is great to have an automated testing during development.

BUT,

How can I build the production release without nunit being included?

THX.

John
p.s. I posted this in nunit group but seems there are not much activity
there.


While keeping the test code in a seperate assembly is the recommended
way, it is pretty easy to do it in one assembly.

Just use the #if statement like this.

#if DEBUG

public class TestCode
{
//
}

#endif
Note, that the NUnit dlls will still be included in the build, but
removing them manually (or not including them in the setup) works
fine. Unless the JIT compiler actually needs the dlls, it won't miss
them.

A somewhat nicer alternative is to place all NUnit specific code in
another assembly, and only place the minimal amount of test code that
is needed to call internal/private methods inside the code assembly
(That test code should still be surrounded by #if DEBUG though). It is
a good compromise in my opinion, unless you want to use reflection to
do tests.

--
Marcus Andrén
Jun 21 '06 #5
"Marcus Andrén" <a@b.c> wrote in message
news:a3******** *************** *********@4ax.c om...
A somewhat nicer alternative is to place all NUnit specific code in
another assembly, and only place the minimal amount of test code that
is needed to call internal/private methods inside the code assembly
(That test code should still be surrounded by #if DEBUG though). It is
a good compromise in my opinion, unless you want to use reflection to
do tests.


That's an interesting idea. The only problem I have with using #if DEBUG is
that it means you're shipping different code than you're testing.

///ark
Jun 21 '06 #6
Marcus Andrén <a@b.c> wrote:
While keeping the test code in a seperate assembly is the recommended
way, it is pretty easy to do it in one assembly.

Just use the #if statement like this.

#if DEBUG

public class TestCode
{
//
}

#endif


Don't forget the handiness of the [Conditional("DE BUG")] attribute
either. Calls to methods marked with this that don't return a value get
removed from the compiled version etc.

-- Barry

--
http://barrkel.blogspot.com/
Jun 21 '06 #7
I was thinking of three configuration:
Debug, with nunit,
Release, with nunit,
and
ProductionRelea se, w/o nunit.

This way, I am still shipping the same code except with the tests
removed. And I don't need to shipping the nunit dll either.

THX

Jun 21 '06 #8
Q. John Chen wrote:
I also need to test "internal" classes.


Some would argue that you don't need to test internal classes, because
you only want to make sure your public API doesn't change.

I'm not one of those though...

If you're using .Net 2.0, you can use the InternalVisible To assembly
attribute in your code assembly, to allow the test assembly to see
internals.

If not, I'm not sure the best way to proceed.

Jun 22 '06 #9
"Andy" <aj*****@alum.r it.edu> wrote in message
news:11******** **************@ b68g2000cwa.goo glegroups.com.. .
If you're using .Net 2.0, you can use the InternalVisible To assembly
attribute in your code assembly, to allow the test assembly to see
internals.


OMG, C# has friends!!

(It's actually InternalsVisibl eTo)

///ark
Jun 22 '06 #10

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

Similar topics

5
2284
by: Theodore Feldman | last post by:
Hi, Our DBA group is debating production release methodology. We always perfect our deployment package (typically a script) against the database in a Staging environment, before executing the package against Production. One side argues that the safest approach is to create a script containing all schema changes, data changes, stored...
3
1929
by: Finn J Johnsen | last post by:
Hi Dow do I get ndoc to ignore classes flagged with the attribute? Thanks, Finn Johnsen
0
1730
by: Greg Bacon | last post by:
I have two C# projects: a production project and NUnit tests for it. I've recently added a test that causes a call into a registered COM component, and now the test fails with a TypeLoadException when it tries to load the interop assembly. However, when I use the TestDriven.NET addin -- run via either Debugger or In-Proc -- the test runs...
6
3473
by: Marco Zapletal | last post by:
hi list, i have an c# project, which contains some additional classes (nunit testclasses), which are not needed in a release build? is it possible to exclude them in the release build process? i dont want to put the nunit tests in another project, because then i have to switch the access modifiers from internal to public for the classes...
2
1310
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 not so when I do a release build I am not compiling in the test cases. This seems to be working all fine and dandy, but I was wondering if there is...
20
2000
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. Hence can someone who has used them before share his/her experience on them so that I can get a better idea and make a proper choice ? Any link or...
4
2382
by: David Thielen | last post by:
Hi; Are there mock objects anywhere that I can use to write nunit tests for my code behind methods? -- thanks - dave david_at_windward_dot_net http://www.windwardreports.com
4
1789
by: Davis Ford | last post by:
Hi, I have a DLL project that implements the Model/Controller part of MVC, and the client of the DLL would be the View. The interface the View consumes is the Controller API, and the Model is marked internal, b/c the View shouldn't need to get at it, but this means I can no longer test the Model unless my NUnit tests exist inside the DLL...
3
3371
by: =?Utf-8?B?bG10dGFn?= | last post by:
We have developed a number of different applications (ASP.NET web site, Windows services, DLLs, Windows forms, etc.) in C# 2.0. We have developed and unit tested all these applications/components using Debug mode. Now we are ready to compile everything for release to production. However, we don’t know whether we should compile all the...
0
7908
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7836
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7950
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
1
5710
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5389
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3835
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3863
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2343
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1447
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.