?
Solved

Test Cases in C/C++

Posted on 2011-03-02
5
Medium Priority
?
373 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 32

Accepted Solution

by:
phoffric earned 1000 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 1000 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 1000 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 1000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

649 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