[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 385
  • Last Modified:

Test Cases in C/C++

Can I get some links / resources that talk about writing test cases in C/C++

Thanks!
0
dshrenik
Asked:
dshrenik
  • 2
  • 2
4 Solutions
 
phoffricCommented:
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
 
trinitrotolueneCommented:
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
 
dshrenikAuthor Commented:
I don't want to use any tools. I want to write my own code for testing. Any tutorials on those lines?

Thanks!
0
 
phoffricCommented:
>>  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
 
trinitrotolueneCommented:
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now