Solved

Test Cases in C/C++

Posted on 2011-03-02
5
337 Views
Last Modified: 2012-06-22
Can I get some links / resources that talk about writing test cases in C/C++

Thanks!
0
Comment
Question by:dshrenik
  • 2
  • 2
5 Comments
 
LVL 32

Accepted Solution

by:
phoffric earned 250 total points
ID: 35022928
System Test Cases deal with testing the requirements specification. These tests are usually black box testing. System testing often includes stress testing which puts "a greater emphasis on robustness, availability, and error handling under a heavy load,"
   http://en.wikipedia.org/wiki/Stress_testing
And it also includes capacity testing which in some companies means to test the maximum performance requirements for which the system runs smoothly without any need for error handling.

When writing requirements, care should be taken to be sure that each requirement can be tested without heroic efforts, since that could result in a test not being written. What good is a requirement if you cannot test it?

There are many other forms of testing that are important. Here is an article on Code Coverage Analysis which is usually necessary in unit testing to satisfy many customers:
  http://www.bullseye.com/coverage.html 

"With white-box testing, you must run the code with predetermined input and check to make
sure that the code produces predetermined outputs. Often programmers write stubs and
drivers for white-box testing. A driver is a software module used to invoke a module under
test and, often, provide test inputs, control and monitor execution, and report test results
(IEEE, 1990) or most simplistically a line of code that calls a method and passes that method
a value."
     http://agile.csc.ncsu.edu/SEMaterials/WhiteBox.pdf

This paper uses UML Activity Diagrams for scenario based white box testing.
    http://dspace.nitrkl.ac.in:8080/dspace/bitstream/2080/833/1/biswal.pdf

All my projects used UML Sequence Diagram Scenario white box testing (using CPPUnit Test).
    http://www.stickyminds.com/sitewide.asp?Function=edetail&ObjectType=ART&ObjectId=3718


Some Test Case Tools:
  cunit:
    http://cunit.sourceforge.net/

  cppunit:
    http://sourceforge.net/apps/mediawiki/cppunit/index.php?title=Main_Page

  boost testing:
    http://www.boost.org/doc/libs/1_44_0/libs/test/doc/html/utf.html 
0
 
LVL 12

Assisted Solution

by:trinitrotoluene
trinitrotoluene earned 250 total points
ID: 35032527
There's a world of tools out there and you could get lost in the jungle. If you have the time take a look at the article below

http://gamesfromwithin.com/exploring-the-c-unit-testing-framework-jungle

Apart from that I would also recommend that you take a look at

TUT

WinUnit and ofcourse

CUTEE
0
 

Author Comment

by:dshrenik
ID: 35032670
I don't want to use any tools. I want to write my own code for testing. Any tutorials on those lines?

Thanks!
0
 
LVL 32

Assisted Solution

by:phoffric
phoffric earned 250 total points
ID: 35032737
>>  I want to write my own code for testing.
You can download existing code and adapt it to your needs.

CUnit:
CUnit-2.1-2-src.tar.bz2 has source code, documentation, and examples for automated testing. Download here:
     http://sourceforge.net/projects/cunit/files/CUnit/2.1-2/CUnit-2.1-2-src.tar.bz2/download

CPPUnit:
cppunit-cvs-repo-archive.tar.bz2 has source code, documentation, and examples.
         http://sourceforge.net/projects/cppunit/files/SVN%20Migration%20Archive/cppunit-cvs-repo-archive.tar.bz2/download

The documentation and examples should serve as a tutorial for you.
0
 
LVL 12

Assisted Solution

by:trinitrotoluene
trinitrotoluene earned 250 total points
ID: 35032768
yes I understand that. That's the reason I'm suggesting you take a look at TUT. It is not a library per se and it only has header files which will assist you in writing your own unit tests.

You could ofcourse write your own unit tests by adding in some test functions written in C++. These could co-exist with your code and all you would need to do is just use a compile switch which would either turn on or turn off the function.

So when you are in the Development phase just compile these functions and when you are ready to release turn off the switch so that you don't compile the functions into the build.

Here's an article about how to approach the task of writing unit tests.
http://www.codeproject.com/KB/architecture/FirstUnitTest.aspx

My suggestion ofcourse is this : Don't re-invent the wheel when its already there.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to jump to matching brace in eclipse editor ? 1 264
C++ Language error 28 186
Super Scope, DHCP 5 51
Using popen() and gunzip() to open file in HTTPServer 6 45
This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now