Unit Testing C++ Code CppUnit by Example Venkat Subramaniam
|
|
|
- Shawn Lucas
- 9 years ago
- Views:
Transcription
1 Unit Testing C++ Code CppUnit by Example Venkat Subramaniam Abstract JUnit for Java popularized unit testing and developers using different languages are benefiting from appropriate tools to help with unit testing. In this article, I show using examples how to create unit tests for your C++ applications. Why sudden interest in C++? I have been asked at least three times in the past few weeks Unit testing is cool, but how do I do that in my C++ application? I figured, if my clients are interested in it, there should be general wider interest out there in that topic and so decided to write this article. Assuming your familiarity with Unit Testing In this article, I assume you are familiar with unit testing. There are some great books to read on that topic (I ve listed my favorites 1, 2 in the references section). You may also refer to my article on Unit Testing 3. How is Unit Testing different in C++? Java and C# (VB.NET) have a feature that C++ does not reflection. If you have used JUnit 4 or NUnit 5, you know how (easy it is) to write a test case. You either derived from a TestCase class in the case of Java or you mark your class with a TestFixture attribute in the case of.net (With Java 5 s annotation, you may also look forward, in JUnit 4.0, to marking your Java test case instead of extending TestCase). Using reflection the unit testing tool (JUnit/NUnit) finds your test methods dynamically. Since C++ does not have support for reflection, it becomes a bit of a challenge to write a unit test in C++, at least the JUnit way. You will have to exploit some of the traditional features of C++ to get around the lack of reflection feature. How to tell what your tests are? In C++, how can you make the program know of the presence of a certain object dynamically or automatically? You can do that by registering an instance of your class with a static or global collection. Let s understand this with an example. If you are an expert in C++, browse through this section. If you will benefit from this example, then read it carefully and try it out for yourself. Let s assume we have different types of Equipment: Equipment1, Equipment2, etc. More Equipment types may be added or some may be removed. We want to find what kind of equipment is available for us to use. The following code does just that. Let s take a look at it step by step. #include <string> using namespace std;
2 class Equipment public: virtual string info() = 0; ; Equipment is defined an abstract base class with a pure virtual function info(). #include "Equipment.h" #include <vector> class EquipmentCollection public: static void add(equipment* pequipment) if (pequipmentlist == NULL) pequipmentlist = new vector<equipment*>(); pequipmentlist->push_back(pequipment); ~EquipmentCollection() delete pequipmentlist; static vector<equipment*>& get() return *pequipmentlist; private: static vector<equipment*>* pequipmentlist; ; EquipmentCollection holds a collection (vector) of Equipment through a static pointer pequipmentlist. This static pointer is assigned to an instance of vector<equipment*>, an instance of vector of Equipment pointers, the first time the add() method is called (the given code is not thread-safe). In the add() method, we add the pointer to the given Equipment to the collection. The collection is initialized in the EquipmentCollection.cpp file as shown below: //EquipmentCollection.cpp #include "EquipmentCollection.h" vector<equipment*>* EquipmentCollection::pEquipmentList = NULL; How are elements placed into this collection? I use a class EquipmentHelper to do this: #include "EquipmentCollection.h" class EquipmentHelper
3 public: EquipmentHelper(Equipment* pequipment) EquipmentCollection::add(pEquipment); ; The constructor of EquipmentHelper receives Equipment and adds it to the collection. Equipment1 is shown below: #include "EquipmentHelper.h" class Equipment1 : public Equipment public: virtual string info() return "Equipment1"; private: static EquipmentHelper helper; ; The class holds a static instance of EquipmentHelper. The static instance is initialized as shown below in the Equipment1.cpp file: //Equipment1.cpp #include "Equipment1.h" EquipmentHelper Equipment1::helper(new Equipment1()); The helper is provided with an instance of Equipment1 which it registers with the collection in EquipmentCollection. Similarly, I have another class Equipment2 with a static member variable named helper of type EquipmentHelper and it is given an instance of Equipment2 (I have not shown the code as it is similar to the code for Equipment1). You may write other classes (like Equipment3, Equipment4, etc.) similarly. Let s take a closer look at what s going on. When a C++ program starts up, before the code in main() executes, all static members of all the classes are initialized. The order in which these are initialized is, however, unpredictable. The members are initialized to 0 unless some other value is specified. In the example code above, before main starts, the helper within Equiment1, Equipment2, etc. are all initialized, and as a result, the collection of Equipment is setup with an instance of these classes. Now, let s take a look at the main() function. #include "EquipmentCollection.h" #include <iostream> using namespace std;
4 int main(int argc, char* argv[]) cout << "List contains " << endl; vector<equipment*> equipmentlist = EquipmentCollection::get(); vector<equipment*>::iterator iter = equipmentlist.begin(); while(iter!= equipmentlist.end()) cout << (*iter)->info() << endl; iter++; return 0; In main(), I fetch an instance of the collection and iterate over its contents, getting instances of different kinds of Equipment. I invoke the info() method on each Equipment and display the result. The output from the above program is shown below: List contains Equipment1 Equipment2 If you are curious about the above example, go ahead, copy and paste the code above and give it a try. Write your own Equipment3 class and see if main() prints information about it without any change. Now that we have figured out how to dynamically recognize classes being added to our code, let s take a look at using macros to do the job. If you are going to write another Equipment class, like Equipment3, you will have to follow certain steps: 1. You must declare a static member of EquipmentHelper 2. You must initialize it with an instance of you class That is really not that hard to do, however, macros may make it a tad easier. Let s take a look at first defining two macros. ##iinncclluuddee ""EEqquuiippmmeennttCCoolllleeccttiioonn..hh"" #define DECLARE_EQUIPMENT() private: static EquipmentHelper helper; #define DEFINE_EQUIPMENT(TYPE) EquipmentHelper TYPE::helper(new TYPE()); ccllaassss EEqquuiippmmeennttHHeellppeerr ppuubblliicc:: EEqquuiippmmeennttHHeellppeerr((EEqquuiippmmeenntt** ppeeqquuiippmmeenntt)) EEqquuiippmmeennttCCoolllleeccttiioonn::::aadddd((ppEEqquuiippmmeenntt));; ;;
5 Now, I can use these macros to write a class Equipment3 as shown below: #include "EquipmentHelper.h" class Equipment3 : public Equipment public: virtual string info() return "Equipment3"; DECLARE_EQUIPMENT() ; //Equipment3.cpp #include "Equipment3.h" DEFINE_EQUIPMENT(Equipment3) Of course we did not make any change to main(). The output from the program is shown below: List contains Equipment1 Equipment2 Equipment3 There is no guarantee that the program will produce the output in this nice order. You may get a different ordering from what s shown above. OK, let s move on to what we are here for, to see how to write unit tests with CPPUnit. Setting up CPPUnit I am using CPPUnit in this example. Download cppunit tar.gz and uncompress it on your system. On mine, I have uncompressed it in c:\programs. Open CppUnitLibraries.dsw which is located in cppunit \src directory and compile it. I had to build it twice to get a clean compile. After successful build, you should see cppunit \lib directory. Setting up Your Project We will use Visual Studio 2003 to build this example unmanaged C++. Created a console application named MyApp. In Solution Explorer, right click on Source Files and select Add Add New Item. Create a file named Main.cpp as shown here:
6 Write a dummy main() method for now: int main(int argc, char* argv[]) return 0; Right click on the project in Solutions Explorer and select Properties. For the Additional Include Directories for C/C++ properties, enter the directory where you have CPPUnit installed on your machine. I have it under c:\programs directory. So, I entered the following:
7 Modify the Runtime Library in Code Generation as shown below:
8 Set the Enable Run-Time Type Info in Language properties as shown below: Two more steps before we can write code. Under Linker, for General properties, set Additional Library Directories to point to the lib directory under CPPUnit as shown below:
9 Finally, set the Additional Dependencies in Input as shown below: Running your unit test Let s now create a Unit Test. We will start in Main.cpp that we have created in the last section. Modify that file as shown below: 1: #include <cppunit/compileroutputter.h> 2: #include <cppunit/extensions/testfactoryregistry.h> 3: #include <cppunit/ui/text/testrunner.h> 4: 5: using namespace CppUnit; 6: 7: int main(int argc, char* argv[]) 8: 9: CppUnit::Test* suite = 10: CppUnit::TestFactoryRegistry::getRegistry().makeTest(); 11: 12: CppUnit::TextUi::TestRunner runner; 13: runner.addtest( suite ); 14: 15: runner.setoutputter( new CppUnit::CompilerOutputter( 16: &runner.result(), std::cerr ) ); 17: 18: return runner.run()? 0 : 1; 19:
10 In lines 1 to 3, we have included the necessary header files from CPPUnit. The CompilerOutputter class is useful to display the results from the run of a test. The TestFactoryRegistry class keeps a collection of tests (this is like the EquipmentCollection class we saw in our example). The TestRunner class will execute each test from the test classes we register with the TestFactoryRegistry. This is like the code that iterated though the Equipment collection in our example. In that example, we iterated and printed the result of info() method invocation. TestRunner does something useful runs your tests. In lines 9 and 10, I invoke the TestFactoryRegistry s getregistry() method and invoke its maketest()method. This call will return all the tests found in your application. In lines 12 through 16, I have created a TestRunner object, the one that will take care of running the tests and reporting the output using the CompilerOutputter. The CompilerOutputter will format the error messages in the compiler compatible format the same format as the compiler errors so you can easily identify the problem areas and also this facilitates IDEs to jump to the location of the error in your test run. Finally in line 18, I ask the tests to run. We haven t written any tests yet. That is OK, let s go ahead and give this a try. Go ahead, compile the code and run it. You should get the following output: OK (0) This says that all is well (after all there is not a whole lot we have done to mess up!) and that no tests were found. Writing unit tests We will take the test first driven approach 1,3 to writing our code. We will build a simple calculator with two methods, add() and divide(). Let s start by creating a Test class as shown below: // CalculatorTest.h #include <cppunit/extensions/helpermacros.h> using namespace CppUnit; class CalculatorTest : public TestFixture CPPUNIT_TEST_SUITE(CalculatorTest); CPPUNIT_TEST_SUITE_END(); ; // CalculatorTest.cpp #include "CalculatorTest.h" CPPUNIT_TEST_SUITE_REGISTRATION(CalculatorTest);
11 You may study the macros I have used in the header file. I will expand here on the macro I have used in the cpp file, that is CPPUNIT_TEST_SUITE_REGISTRATION: #define CPPUNIT_TEST_SUITE_REGISTRATION( ATestFixtureType ) \ static CPPUNIT_NS::AutoRegisterSuite< ATestFixtureType > \ CPPUNIT_MAKE_UNIQUE_NAME(autoRegisterRegistry ) Notice the creation of a static object. This object will take care of registering the test fixture object with the test registry. Now, let s go ahead and write a test: // CalculatorTest.h #include <cppunit/extensions/helpermacros.h> using namespace CppUnit; class CalculatorTest : public TestFixture CPPUNIT_TEST_SUITE(CalculatorTest); CPPUNIT_TEST(testAdd); CPPUNIT_TEST_SUITE_END(); public: void testadd() ; I have created a method testadd() and have declared a macro CPPUNIT_TEST to introduce that method as a test. Let s compile and execute this code. The output is shown below:. OK (1) The above output shows that one test was executed successfully. Let s modify the test code to use the Calculator: void testadd() Calculator calc; CPPUNIT_ASSERT_EQUAL(5, calc.add(2, 3)); I am using the CPPUNIT_ASSERT_EQUAL to assert that the method add returns the expected value of 5. Let s create the Calculator class and write the add() method as shown below:
12 #pragma once class Calculator public: Calculator(void); virtual ~Calculator(void); ; int add(int op1, int op2) return 0; Let s execute the test and see what the output is:.f c:\...\calculatortest.h(20) : error : Assertion Test name: CalculatorTest::testAdd equality assertion failed - Expected: 5 - Actual : 0 Failures!!! Run: 1 Failure total: 1 Failures: 1 Errors: 0 The output shows us that my test failed (obviously as I am returning a 0 in the add() method). Let s fix the code now to return op1 + op2. The output after the fix is:. OK (1) Let s write a test for the divide() method as shown below: void testdivide() Calculator calc; CPPUNIT_ASSERT_EQUAL(2.0, calc.divide(6, 3)); Remember to add CPPUNIT_TEST(testDivide); as well. Now the divide() method in the Calculator class looks like this:
13 double divide(int op1, int op2) return op1/op2; The output is shown below:.. OK (2) It shows us that two tests were executed successfully. Let s write one more test, this time a negative test: void testdividebyzero() Calculator calc; calc.divide(6, 0); We are testing for division by zero. Intentionally I have not added any asserts yet. If we run this, we get:...e ##Failure Location unknown## : Error Test name: CalculatorTest::testDivideByZero uncaught exception of unknown type Failures!!! Run: 3 Failure total: 1 Failures: 0 Errors: 1 CppUnit tells us that there was an exception from the code. Indeed, we should get an exception. But the success of this test is the method divide throwing the exception. So, the test must have reported a success and not a failure. How can we do that? This is where CPP_FAIL comes in: void testdividebyzero() Calculator calc; try calc.divide(6, 0); CPPUNIT_FAIL( "Expected division by zero to throw exception!!!!"); catch(exception ex) // Fail throws Exception, //we will throw in back to CppUnit to handle
14 throw; catch(...) // Division by Zero in this case. Good. If the method divide() throws an exception, then we are good. If the method does not throw exception, then we force fail this test by call to the CPPUNIT_FAIL. Let s run the test now:... OK (3) We have passing tests. Reexamining the Divide by Zero Let s make a change to the divide() method in Calculator we will make the method take double instead of int as parameters. double divide(double op1, double op2) return op1/op2; Let s rerun out tests and see what we get:...f c:\agility\myapp\calculatortest.h(39) : error : Assertion Test name: CalculatorTest::testDivideByZero forced failure - Expected division by zero to throw exception!!!! Failures!!! Run: 3 Failure total: 1 Failures: 1 Errors: 0 CppUnit tells us that the division by zero did not throw the exception as expected! The reason is the behavior of floating point division is different from the integer division. While integer division by zero throws an exception, division by zero for double returns infinity. This further illustrates how CPPUNIT_FAIL helps. Conclusion If you are a C++ developer, you can take advantage of unit testing using CppUnit. Since C++ does not provide some features of Java and.net languages, you have to work around those limitations. However, CppUnit addresses these by providing helper macros. We first took time to see how in C++ we can identify classes automatically. Then we delved into examples of using CppUnit.
15 References 1. Test Driven Development: By Example, Kent Beck. 2. Pragmatic Unit Testing in C# with NUnit, Andy Hunt, Dave Thomas. 3. Test Driven Development Part I: TFC,
Comp151. Definitions & Declarations
Comp151 Definitions & Declarations Example: Definition /* reverse_printcpp */ #include #include using namespace std; int global_var = 23; // global variable definition void reverse_print(const
Visual Studio 2008 Express Editions
Visual Studio 2008 Express Editions Visual Studio 2008 Installation Instructions Burning a Visual Studio 2008 Express Editions DVD Download (http://www.microsoft.com/express/download/) the Visual Studio
Introduction to C Unit Testing (CUnit) Brian Nielsen Arne Skou
Introduction to C Unit Testing (CUnit) Brian Nielsen Arne Skou {bnielsen ask}@cs.auc.dk Unit Testing Code that isn t tested doesn t work Code that isn t regression tested suffers from code rot (breaks
Agile.NET Development Test-driven Development using NUnit
Agile.NET Development Test-driven Development using NUnit Jason Gorman Test-driven Development Drive the design and construction of your code on unit test at a time Write a test that the system currently
An Incomplete C++ Primer. University of Wyoming MA 5310
An Incomplete C++ Primer University of Wyoming MA 5310 Professor Craig C. Douglas http://www.mgnet.org/~douglas/classes/na-sc/notes/c++primer.pdf C++ is a legacy programming language, as is other languages
Appendix K Introduction to Microsoft Visual C++ 6.0
Appendix K Introduction to Microsoft Visual C++ 6.0 This appendix serves as a quick reference for performing the following operations using the Microsoft Visual C++ integrated development environment (IDE):
Storage Classes CS 110B - Rule Storage Classes Page 18-1 \handouts\storclas
CS 110B - Rule Storage Classes Page 18-1 Attributes are distinctive features of a variable. Data type, int or double for example, is an attribute. Storage class is another attribute. There are four storage
C++ INTERVIEW QUESTIONS
C++ INTERVIEW QUESTIONS http://www.tutorialspoint.com/cplusplus/cpp_interview_questions.htm Copyright tutorialspoint.com Dear readers, these C++ Interview Questions have been designed specially to get
JUnit Automated Software Testing Framework. Jeff Offutt. SWE 437 George Mason University 2008. Thanks in part to Aynur Abdurazik. What is JUnit?
JUnit Automated Software Testing Framework Jeff Offutt SWE 437 George Mason University 2008 Thanks in part to Aynur Abdurazik What is JUnit? Open source Java testing framework used to write and run repeatable
Creating a Simple Visual C++ Program
CPS 150 Lab 1 Name Logging in: Creating a Simple Visual C++ Program 1. Once you have signed for a CPS computer account, use the login ID and the password password (lower case) to log in to the system.
Unit Testing and JUnit
Unit Testing and JUnit Testing Objectives Tests intended to find errors Errors should be found quickly Good test cases have high p for finding a yet undiscovered error Successful tests cause program failure,
CORBA Programming with TAOX11. The C++11 CORBA Implementation
CORBA Programming with TAOX11 The C++11 CORBA Implementation TAOX11: the CORBA Implementation by Remedy IT TAOX11 simplifies development of CORBA based applications IDL to C++11 language mapping is easy
MS Visual C++ Introduction. Quick Introduction. A1 Visual C++
MS Visual C++ Introduction 1 Quick Introduction The following pages provide a quick tutorial on using Microsoft Visual C++ 6.0 to produce a small project. There should be no major differences if you are
Calling the Function. Two Function Declarations Here is a function declared as pass by value. Why use Pass By Reference?
Functions in C++ Let s take a look at an example declaration: Lecture 2 long factorial(int n) Functions The declaration above has the following meaning: The return type is long That means the function
Lazy OpenCV installation and use with Visual Studio
Lazy OpenCV installation and use with Visual Studio Overview This tutorial will walk you through: How to install OpenCV on Windows, both: The pre-built version (useful if you won t be modifying the OpenCV
Creating a Java application using Perfect Developer and the Java Develo...
1 of 10 15/02/2010 17:41 Creating a Java application using Perfect Developer and the Java Development Kit Introduction Perfect Developer has the facility to execute pre- and post-build steps whenever the
CSI33 Data Structures
Outline Department of Mathematics and Computer Science Bronx Community College November 25, 2015 Outline Outline 1 Chapter 12: C++ Templates Outline Chapter 12: C++ Templates 1 Chapter 12: C++ Templates
Class 16: Function Parameters and Polymorphism
Class 16: Function Parameters and Polymorphism SI 413 - Programming Languages and Implementation Dr. Daniel S. Roche United States Naval Academy Fall 2011 Roche (USNA) SI413 - Class 16 Fall 2011 1 / 15
Developing an ODBC C++ Client with MySQL Database
Developing an ODBC C++ Client with MySQL Database Author: Rajinder Yadav Date: Aug 21, 2007 Web: http://devmentor.org Email: [email protected] Assumptions I am going to assume you already know how
Illustration 1: Diagram of program function and data flow
The contract called for creation of a random access database of plumbing shops within the near perimeter of FIU Engineering school. The database features a rating number from 1-10 to offer a guideline
CSE 326: Data Structures. Java Generics & JUnit. Section notes, 4/10/08 slides by Hal Perkins
CSE 326: Data Structures Java Generics & JUnit Section notes, 4/10/08 slides by Hal Perkins Type-Safe Containers Idea a class or interface can have a type parameter: public class Bag { private E item;
Licensed for viewing only. Printing is prohibited. For hard copies, please purchase from www.agileskills.org
Unit Test 301 CHAPTER 12Unit Test Unit test Suppose that you are writing a CourseCatalog class to record the information of some courses: class CourseCatalog { CourseCatalog() { void add(course course)
Basics of I/O Streams and File I/O
Basics of This is like a cheat sheet for file I/O in C++. It summarizes the steps you must take to do basic I/O to and from files, with only a tiny bit of explanation. It is not a replacement for reading
Unit Testing. and. JUnit
Unit Testing and JUnit Problem area Code components must be tested! Confirms that your code works Components must be tested t in isolation A functional test can tell you that a bug exists in the implementation
JUnit. Introduction to Unit Testing in Java
JUnit Introduction to Unit Testing in Java Testing, 1 2 3 4, Testing What Does a Unit Test Test? The term unit predates the O-O era. Unit natural abstraction unit of an O-O system: class or its instantiated
Eclipse installation, configuration and operation
Eclipse installation, configuration and operation This document aims to walk through the procedures to setup eclipse on different platforms for java programming and to load in the course libraries for
Test Automation Integration with Test Management QAComplete
Test Automation Integration with Test Management QAComplete This User's Guide walks you through configuring and using your automated tests with QAComplete's Test Management module SmartBear Software Release
The C Programming Language course syllabus associate level
TECHNOLOGIES The C Programming Language course syllabus associate level Course description The course fully covers the basics of programming in the C programming language and demonstrates fundamental programming
Unit Testing with JUnit and CppUnit
Unit Testing with JUnit and CppUnit Software Testing Fundamentals (1) What is software testing? The process of operating a system or component under specified conditions, observing or recording the results,
This section provides a 'Quickstart' guide to using TestDriven.NET any version of Microsoft Visual Studio.NET
Quickstart TestDriven.NET - Quickstart TestDriven.NET Quickstart Introduction Installing Running Tests Ad-hoc Tests Test Output Test With... Test Projects Aborting Stopping Introduction This section provides
Unit Testing & JUnit
Unit Testing & JUnit Lecture Outline Communicating your Classes Introduction to JUnit4 Selecting test cases UML Class Diagrams Rectangle height : int width : int resize(double,double) getarea(): int getperimeter():int
Overview. What is software testing? What is unit testing? Why/when to test? What makes a good test? What to test?
Testing CMSC 202 Overview What is software testing? What is unit testing? Why/when to test? What makes a good test? What to test? 2 What is Software Testing? Software testing is any activity aimed at evaluating
1. The First Visual C++ Program
1. The First Visual C++ Program Application and name it as HelloWorld, and unselect the Create directory for solution. Press [OK] button to confirm. 2. Select Application Setting in the Win32 Application
+ Introduction to JUnit. IT323 Software Engineering II By: Mashael Al-Duwais
1 + Introduction to JUnit IT323 Software Engineering II By: Mashael Al-Duwais + What is Unit Testing? 2 A procedure to validate individual units of Source Code Example: A procedure, method or class Validating
Running your first Linux Program
Running your first Linux Program This document describes how edit, compile, link, and run your first linux program using: - Gnome a nice graphical user interface desktop that runs on top of X- Windows
Copyright 2001, Bill Trudell. Permission is granted to copy for the PLoP 2001 conference. All other rights reserved.
The Secret Partner Pattern Revision 3a by Bill Trudell, July 23, 2001 Submitted to the Pattern Languages of Programs Shepherd: Neil Harrison PC Member: Kyle Brown Thumbnail This paper describes the Secret
TESTING WITH JUNIT. Lab 3 : Testing
TESTING WITH JUNIT Lab 3 : Testing Overview Testing with JUnit JUnit Basics Sample Test Case How To Write a Test Case Running Tests with JUnit JUnit plug-in for NetBeans Running Tests in NetBeans Testing
Appendix M: Introduction to Microsoft Visual C++ 2010 Express Edition
Appendix M: Introduction to Microsoft Visual C++ 2010 Express Edition This book may be ordered from Addison-Wesley in a value pack that includes Microsoft Visual C++ 2010 Express Edition. Visual C++ 2010
Test Driven Development Part III: Continuous Integration Venkat Subramaniam [email protected] http://www.agiledeveloper.com/download.
Test Driven Development Part III: Continuous Integration Venkat Subramaniam [email protected] http://www.agiledeveloper.com/download.aspx Abstract In this final part of the three part series on
Using Visual C++ and Pelles C
Using Visual C++ and Pelles C -IDE & Compilerswww.tenouk.com, 1/48 (2008) In this session we will learn how to use VC++ to build a sample C program. We assume VC++ (Visual Studio) was successfully installed.
Object Oriented Software Design II
Object Oriented Software Design II Introduction to C++ Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa February 20, 2012 G. Lipari (Scuola Superiore Sant Anna) C++ Intro February
Introduction to Data Structures
Introduction to Data Structures Albert Gural October 28, 2011 1 Introduction When trying to convert from an algorithm to the actual code, one important aspect to consider is how to store and manipulate
Java Unit testing with JUnit 4.x in Eclipse
Lars Vogel Version 0.2 Copyright 2007 Lars Vogel 30.06.2007 Abstract This article gives a short overview of JUnit 4.x and its usage within Eclipse. You should be able to run tests
Object-Oriented Design Lecture 4 CSU 370 Fall 2007 (Pucella) Tuesday, Sep 18, 2007
Object-Oriented Design Lecture 4 CSU 370 Fall 2007 (Pucella) Tuesday, Sep 18, 2007 The Java Type System By now, you have seen a fair amount of Java. Time to study in more depth the foundations of the language,
Answers to Review Questions Chapter 7
Answers to Review Questions Chapter 7 1. The size declarator is used in a definition of an array to indicate the number of elements the array will have. A subscript is used to access a specific element
The full setup includes the server itself, the server control panel, Firebird Database Server, and three sample applications with source code.
Content Introduction... 2 Data Access Server Control Panel... 2 Running the Sample Client Applications... 4 Sample Applications Code... 7 Server Side Objects... 8 Sample Usage of Server Side Objects...
Designing with Exceptions. CSE219, Computer Science III Stony Brook University http://www.cs.stonybrook.edu/~cse219
Designing with Exceptions CSE219, Computer Science III Stony Brook University http://www.cs.stonybrook.edu/~cse219 Testing vs. Debugging Testing Coding Does the code work properly YES NO 2 Debugging Testing
SpiraTest / SpiraTeam Automated Unit Testing Integration & User Guide Inflectra Corporation
SpiraTest / SpiraTeam Automated Unit Testing Integration & User Guide Inflectra Corporation Date: October 3rd, 2014 Contents 1. Introduction... 1 2. Integrating with NUnit... 2 3. Integrating with JUnit...
Java Interview Questions and Answers
1. What is the most important feature of Java? Java is a platform independent language. 2. What do you mean by platform independence? Platform independence means that we can write and compile the java
Unit Testing JUnit and Clover
1 Unit Testing JUnit and Clover Software Component Technology Agenda for Today 2 1. Testing 2. Main Concepts 3. Unit Testing JUnit 4. Test Evaluation Clover 5. Reference Software Testing 3 Goal: find many
C++FA 3.1 OPTIMIZING C++
C++FA 3.1 OPTIMIZING C++ Ben Van Vliet Measuring Performance Performance can be measured and judged in different ways execution time, memory usage, error count, ease of use and trade offs usually have
Getting Started with the Internet Communications Engine
Getting Started with the Internet Communications Engine David Vriezen April 7, 2014 Contents 1 Introduction 2 2 About Ice 2 2.1 Proxies................................. 2 3 Setting Up ICE 2 4 Slices 2
Chapter 9 Delegates and Events
Chapter 9 Delegates and Events Two language features are central to the use of the.net FCL. We have been using both delegates and events in the topics we have discussed so far, but I haven t explored the
Netscape Internet Service Broker for C++ Programmer's Guide. Contents
Netscape Internet Service Broker for C++ Programmer's Guide Page 1 of 5 [Next] Netscape Internet Service Broker for C++ Programmer's Guide Nescape ISB for C++ - Provides information on how to develop and
Testing, Debugging, and Verification
Testing, Debugging, and Verification Testing, Part II Moa Johansson 10 November 2014 TDV: Testing /GU 141110 1 / 42 Admin Make sure you are registered for the course. Otherwise your marks cannot be recorded.
Going Interactive: Combining Ad-Hoc and Regression Testing
Going Interactive: Combining Ad-Hoc and Regression Testing Michael Kölling 1, Andrew Patterson 2 1 Mærsk Mc-Kinney Møller Institute, University of Southern Denmark, Denmark [email protected] 2 Deakin University,
Crash Course in Java
Crash Course in Java Based on notes from D. Hollinger Based in part on notes from J.J. Johns also: Java in a Nutshell Java Network Programming and Distributed Computing Netprog 2002 Java Intro 1 What is
First Java Programs. V. Paúl Pauca. CSC 111D Fall, 2015. Department of Computer Science Wake Forest University. Introduction to Computer Science
First Java Programs V. Paúl Pauca Department of Computer Science Wake Forest University CSC 111D Fall, 2015 Hello World revisited / 8/23/15 The f i r s t o b l i g a t o r y Java program @author Paul Pauca
Test Driven Development
Test Driven Development Introduction Test Driven development (TDD) is a fairly recent (post 2000) design approach that originated from the Extreme Programming / Agile Methodologies design communities.
Informatica e Sistemi in Tempo Reale
Informatica e Sistemi in Tempo Reale Introduction to C programming Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa October 25, 2010 G. Lipari (Scuola Superiore Sant Anna)
Chapter 5 Functions. Introducing Functions
Chapter 5 Functions 1 Introducing Functions A function is a collection of statements that are grouped together to perform an operation Define a function Invoke a funciton return value type method name
MAHALAKSHMI ENGINEERING COLLEGE B TIRUCHIRAPALLI 621213
MAHALAKSHMI ENGINEERING COLLEGE B TIRUCHIRAPALLI 621213 DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING Sub code: CS2203 SEM: III Sub Name: Object Oriented Programming Year: II UNIT-IV PART-A 1. Write the
Drawing Text with SDL
Drawing Text with SDL Note: This tutorial assumes that you already know how to display a window and draw a sprite with SDL. Setting Up the SDL TrueType Font Library To display text with SDL, you need the
Lab 2 - CMPS 1043, Computer Science I Introduction to File Input/Output (I/O) Projects and Solutions (C++)
Lab 2 - CMPS 1043, Computer Science I Introduction to File Input/Output (I/O) Projects and Solutions (C++) (Revised from http://msdn.microsoft.com/en-us/library/bb384842.aspx) * Keep this information to
Test-Driven Development
Test-Driven Development An Introduction Mattias Ståhlberg [email protected] Debugging sucks. Testing rocks. Contents 1. What is unit testing? 2. What is test-driven development? 3. Example 4.
Chapter 1: Getting Started
Chapter 1: Getting Started Every journey begins with a single step, and in ours it's getting to the point where you can compile, link, run, and debug C++ programs. This depends on what operating system
PART-A Questions. 2. How does an enumerated statement differ from a typedef statement?
1. Distinguish & and && operators. PART-A Questions 2. How does an enumerated statement differ from a typedef statement? 3. What are the various members of a class? 4. Who can access the protected members
7.7 Case Study: Calculating Depreciation
7.7 Case Study: Calculating Depreciation 1 7.7 Case Study: Calculating Depreciation PROBLEM Depreciation is a decrease in the value over time of some asset due to wear and tear, decay, declining price,
How to test and debug an ASP.NET application
Chapter 4 How to test and debug an ASP.NET application 113 4 How to test and debug an ASP.NET application If you ve done much programming, you know that testing and debugging are often the most difficult
How to create/avoid memory leak in Java and.net? Venkat Subramaniam [email protected] http://www.durasoftcorp.com
How to create/avoid memory leak in Java and.net? Venkat Subramaniam [email protected] http://www.durasoftcorp.com Abstract Java and.net provide run time environment for managed code, and Automatic
Embedded SQL. Unit 5.1. Dr Gordon Russell, Copyright @ Napier University
Embedded SQL Unit 5.1 Unit 5.1 - Embedde SQL - V2.0 1 Interactive SQL So far in the module we have considered only the SQL queries which you can type in at the SQL prompt. We refer to this as interactive
Member Functions of the istream Class
Member Functions of the istream Class The extraction operator is of limited use because it always uses whitespace to delimit its reads of the input stream. It cannot be used to read those whitespace characters,
Boolean Expressions, Conditions, Loops, and Enumerations. Precedence Rules (from highest to lowest priority)
Boolean Expressions, Conditions, Loops, and Enumerations Relational Operators == // true if two values are equivalent!= // true if two values are not equivalent < // true if left value is less than the
1 Abstract Data Types Information Hiding
1 1 Abstract Data Types Information Hiding 1.1 Data Types Data types are an integral part of every programming language. ANSI-C has int, double and char to name just a few. Programmers are rarely content
OpenCV Tutorial. Part I Using OpenCV with Microsoft Visual Studio.net 2003. 28 November 2005. Gavin S Page [email protected]
OpenCV Tutorial Part I Using OpenCV with Microsoft Visual Studio.net 2003 28 November 2005 Gavin S Page OpenCV What is OpenCV? (from the documentation) OpenCV means Intel Open Source Computer Vision Library.
Code::Blocks Student Manual
Code::Blocks Student Manual Lawrence Goetz, Network Administrator Yedidyah Langsam, Professor and Theodore Raphan, Distinguished Professor Dept. of Computer and Information Science Brooklyn College of
Implementation Aspects of OO-Languages
1 Implementation Aspects of OO-Languages Allocation of space for data members: The space for data members is laid out the same way it is done for structures in C or other languages. Specifically: The data
Overview of Web Services API
1 CHAPTER The Cisco IP Interoperability and Collaboration System (IPICS) 4.5(x) application programming interface (API) provides a web services-based API that enables the management and control of various
Common Beginner C++ Programming Mistakes
Common Beginner C++ Programming Mistakes This documents some common C++ mistakes that beginning programmers make. These errors are two types: Syntax errors these are detected at compile time and you won't
An Overview of Java. overview-1
An Overview of Java overview-1 Contents What is Java Major Java features Java virtual machine Java programming language Java class libraries (API) GUI Support in Java Networking and Threads in Java overview-2
Vim, Emacs, and JUnit Testing. Audience: Students in CS 331 Written by: Kathleen Lockhart, CS Tutor
Vim, Emacs, and JUnit Testing Audience: Students in CS 331 Written by: Kathleen Lockhart, CS Tutor Overview Vim and Emacs are the two code editors available within the Dijkstra environment. While both
C++FA 5.1 PRACTICE MID-TERM EXAM
C++FA 5.1 PRACTICE MID-TERM EXAM This practicemid-term exam covers sections C++FA 1.1 through C++FA 1.4 of C++ with Financial Applications by Ben Van Vliet, available at www.benvanvliet.net. 1.) A pointer
Android: Setup Hello, World: Android Edition. due by noon ET on Wed 2/22. Ingredients.
Android: Setup Hello, World: Android Edition due by noon ET on Wed 2/22 Ingredients. Android Development Tools Plugin for Eclipse Android Software Development Kit Eclipse Java Help. Help is available throughout
Table of Contents. LESSON: The JUnit Test Tool...1. Subjects...2. Testing 123...3. What JUnit Provides...4. JUnit Concepts...5
Table of Contents LESSON: The JUnit Test Tool...1 Subjects...2 Testing 123...3 What JUnit Provides...4 JUnit Concepts...5 Example Testing a Queue Class...6 Example TestCase Class for Queue...7 Example
Masters programmes in Computer Science and Information Systems. Object-Oriented Design and Programming. Sample module entry test xxth December 2013
Masters programmes in Computer Science and Information Systems Object-Oriented Design and Programming Sample module entry test xxth December 2013 This sample paper has more questions than the real paper
Introduction to Eclipse
Introduction to Eclipse Overview Eclipse Background Obtaining and Installing Eclipse Creating a Workspaces / Projects Creating Classes Compiling and Running Code Debugging Code Sampling of Features Summary
Getting Started Guide
Getting Started Guide Your Guide to Getting Started with IVI Drivers Revision 1.0 Contents Chapter 1 Introduction............................................. 9 Purpose.................................................
C++ Crash Kurs. C++ Object-Oriented Programming
C++ Crash Kurs C++ Object-Oriented Programming Dr. Dennis Pfisterer Institut für Telematik, Universität zu Lübeck http://www.itm.uni-luebeck.de/people/pfisterer C++ classes A class is user-defined type
Using Files as Input/Output in Java 5.0 Applications
Using Files as Input/Output in Java 5.0 Applications The goal of this module is to present enough information about files to allow you to write applications in Java that fetch their input from a file instead
Hypercosm. Studio. www.hypercosm.com
Hypercosm Studio www.hypercosm.com Hypercosm Studio Guide 3 Revision: November 2005 Copyright 2005 Hypercosm LLC All rights reserved. Hypercosm, OMAR, Hypercosm 3D Player, and Hypercosm Studio are trademarks
IVI Configuration Store
Agilent Developer Network White Paper Stephen J. Greer Agilent Technologies, Inc. The holds information about IVI drivers installed on the computer and configuration information for an instrument system.
Effective unit testing with JUnit
Effective unit testing with JUnit written by Eric M. Burke [email protected] Copyright 2000, Eric M. Burke and All rights reserved last revised 12 Oct 2000 extreme Testing 1 What is extreme Programming
How To Test In Bluej
Unit Testing in BlueJ Version 1.0 for BlueJ Version 1.3.0 Michael Kölling Mærsk Institute University of Southern Denmark Copyright M. Kölling 1 INTRODUCTION.........................................................................
Virtuozzo Virtualization SDK
Virtuozzo Virtualization SDK Programmer's Guide February 18, 2016 Copyright 1999-2016 Parallels IP Holdings GmbH and its affiliates. All rights reserved. Parallels IP Holdings GmbH Vordergasse 59 8200
