473,396 Members | 1,891 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.

How to test a class

Tom
I am new to C# and VS.Net. How do I test inidividual classes? I'm used to Java where a Main method for every class to test it. However, VS sees each Main method as an entry point into the .exe. What is the standard procedure for debugging individual classes

Thanks
Nov 16 '05 #1
5 2019
Try can NUnit.
"Tom" <an*******@discussions.microsoft.com> wrote in message
news:95**********************************@microsof t.com...
I am new to C# and VS.Net. How do I test inidividual classes? I'm used to Java where a Main method for every class to test it. However, VS sees each
Main method as an entry point into the .exe. What is the standard procedure
for debugging individual classes?
Thanks

Nov 16 '05 #2
You can use NUnit for your unit test. Here is the URL to NUnit.

http://www.nunit.org/

To give you more idea, I have an automated build going that starts at
12:00a.m. every night for our product. I run NUnit during the automated
build. If NUnit fails, the automated build notifies me telling me what
failed. Implementing NUnit with our automated build has kept the quality of
our software to the next level.

"Tom" <an*******@discussions.microsoft.com> wrote in message
news:95**********************************@microsof t.com...
I am new to C# and VS.Net. How do I test inidividual classes? I'm used to Java where a Main method for every class to test it. However, VS sees each
Main method as an entry point into the .exe. What is the standard procedure
for debugging individual classes?
Thanks

Nov 16 '05 #3
Tom.... Just as in Java, each class in C# can have a main for unit
testing.

http://www.geocities.com/jeff_louie/OOP/oop5.htm

5) The Visual Studio IDE Startup Object is Empty By Default

If the startup object string is empty and you declare more than one
"Main"
method in a Visual Studio project, the project will not compile. This is
very
frustrating. Trying to set the startup object property in the Visual
Studio IDE
is non-trivial. Let me save you some pain. To set the startup object,
select
View --> Solution Explorer. In the Solution Explorer window select the
name
of the project. Now select View --> Property Pages. (Do not select the
Property Window!) Alternatively, right click on the project name and
select
Properties. Now select the Common Properties folder in the left window.
You
can now select the appropriate startup object from the drop down list.
Don't
forget to click on "Apply."

Regards,
Jeff
I am new to C# and VS.Net. How do I test inidividual classes? I'm used

to
Java where a Main method for every class to test it. However, VS sees
each
Main method as an entry point into the .exe. What is the standard
procedure
for debugging individual classes?<<
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #4
Tom wrote:
Jeff,

Thank you for the help and the good web site. I have another question -

Do you know if there is an option in VS.Net (2003), to run an individual class. In JBuilder, I had the option to run or debug any class that had a Main method. I was hoping VS had the same feature.

Tom


Unfortunately, no. You have to reset the 'Startup Object' property for
the project.

However, if you're using various different Main() instances for
debugging purposes like you used to in Java I'd recommend that you look
into using NUnit (http://www.nunit.org) instead.

There is also a good MSDN Magazine article on the subject:

http://msdn.microsoft.com/msdnmag/is...meProgramming/
--

Ed Courtenay
[MCP, MCSD]
http://www.edcourtenay.co.uk
Nov 16 '05 #5
You can use the Main entry point to instanciate any other class -even in
the scenario that you have a two forms. Form1 with the Main as such
Application.Run (new Form2())

In practice I tend to copy the Main entry point and comment out the one I
dont want via /* ....*/
--

--

Br,
Mark Broadbent
mcdba , mcse+i
=============
"Tom" <an*******@discussions.microsoft.com> wrote in message
news:60**********************************@microsof t.com...
Jeff,

Thank you for the help and the good web site. I have another question -

Do you know if there is an option in VS.Net (2003), to run an individual class. In JBuilder, I had the option to run or debug any class that had a
Main method. I was hoping VS had the same feature.
Tom

Nov 16 '05 #6

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

Similar topics

0
by: Remy Blank | last post by:
Ok, here we go. I added the possibility for tests using the unittest.py framework to be skipped. Basically, I added two methods to TestCase: TestCase.skip(msg): skips unconditionally...
4
by: Edvard Majakari | last post by:
Hi, I just found py.test and converted a large unit test module to py.test format (which is actually almost-no-format-at-all, but I won't get there now). Having 348 test cases in the module and...
0
by: Tim Haughton | last post by:
I've just released an article on using Test Driven Development with C# and Windows Forms. GUI's are often difficult to test, so I thought it might be of interest. The article along with the...
5
by: Dmitry Martynov | last post by:
Consider I have the following construction "if(x is T) ...". How much this test cost? And I wonder how it is implemented. Can I gain in performace if I introduce virtual methods like "bool...
6
by: Ben Finney | last post by:
Howdy all, Summary: I'm looking for idioms in unit tests for factoring out repetitive iteration over test data. I explain my current practice, and why it's unsatisfactory. When following...
6
by: ypjofficial | last post by:
HI, I have following terrific confusion. class test { public: int i; int * j; int **k;
3
by: jab3 | last post by:
Hello. I"m new to this group, and to JavaScript in general, so please forgive me if I breach local etiquette. I'm trying to implement some client-side 'dynamic' validation on a form. I'm having...
6
by: Tony Johansson | last post by:
Hello!! If you write private class Test {} you have a private class If you write public class Test {} you have a public class If you write protected class Test {} you have a protected class If...
5
by: shuisheng | last post by:
Dear All, I was told that unit test is a powerful tool for progamming. If I am writing a GUI code, is it possible to still using unit test? I have a little experience in using unittest++. But...
176
by: nw | last post by:
Hi, I previously asked for suggestions on teaching testing in C++. Based on some of the replies I received I decided that best way to proceed would be to teach the students how they might write...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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.