473,406 Members | 2,377 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,406 software developers and data experts.

Unit Testing Exceptions

179 100+
I'm currently in the process of writing a class library, and I'm attempting to write as many unit tests as possible to ensure that I can weed out all the mistakes early on.

Part of this involves testing that various properties catch Exceptions if set to null, so I don't need to extensively check this later on in the program and slow down my heuristics.

What I'm interested in, is if anyone knows of an easy way of testing for Exceptions being thrown, or a better technique than below:

Expand|Select|Wrap|Line Numbers
  1. try
  2. {
  3.    value1 = null   
  4. }
  5. catch(NullReferenceException)
  6. {
  7.    try
  8.    {
  9.      value2 = null;
  10.    }
  11.    catch(NullReferenceException)
  12.    {
  13.       return;
  14.    }
  15. }
  16.  
  17. Assert.Fail("Null Reference Exceptions were not thrown");
  18.  
May 15 '09 #1
3 2477
PRR
750 Expert 512MB
You can take a look at Unit Testing Framework and Visual Studio Team Test
May 18 '09 #2
IanWright
179 100+
@DeepBlue
Interesting... I think I need to explore MSDN a little more than I have already. Thanks DeepBlue.
May 18 '09 #3
PRR
750 Expert 512MB
Welcome Ian... i too need to explore this ...
May 18 '09 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

38
by: Christoph Zwerschke | last post by:
In August 2001, there was a thread about the "Art of Unit Testing": http://groups.google.com/group/comp.lang.python/browse_frm/thread/aa2bd17e7f995d05/71a29faf0a0485d5 Paul Moore asked the...
5
by: Pete | last post by:
Hi folks, I've been looking at unit testing frameworks (csUnit, NUnit, etc) and have gathered some info on them (see the older thread on c# 2004). My question is this: how do they work with...
16
by: Greg Roberts | last post by:
Hi I want to place the tests needed in the code using attributes. There seems to be enough code snippets around for me to cover this. e.g. // Test cases, run these here on the function and...
72
by: Jacob | last post by:
I have compiled a set og unit testing recommendations based on my own experience on the concept. Feedback and suggestions for improvements are appreciated: ...
1
by: listservs | last post by:
I have some unit testing code in one of my modules that appears to run without an error, but the unit test fails anyhow. Have a look at the output below -- the TestResult seems to have no errors...
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...
1
by: rich_sposato | last post by:
I released version 2.0 of C++ Unit Test Library. You can download it from SourceForget.Net at http://sourceforge.net/projects/cppunittest/ .. I wrote this unit test library because other unit...
2
by: =?Utf-8?B?QXJtaW4gR2FsbGlrZXI=?= | last post by:
Hi I've got an unexpected error in a unit test. I want to test a activity from Windows Workflow Foundation (WF). First, I executed the test outside of the activity just in the test-init...
10
by: Brendan Miller | last post by:
What would heavy python unit testers say is the best framework? I've seen a few mentions that maybe the built in unittest framework isn't that great. I've heard a couple of good things about...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: 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
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...
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.