SlideShare una empresa de Scribd logo
1 de 13
Descargar para leer sin conexión
CppUnit


CppUnit usage 
 Workshop

              © 2007­2008 Iurii Kiyan
CppUnit
                             Overview
●
    Introduction
●
    Using CppUnit framework classes for unit testing
         ●
             TestCase
         ●
             TestRunner
         ●
             TestFixture
         ●
             TestSuite
         ●
             Helper Macros
●
    Integration CppUnit in build process
●
    References
                                                       © 2007­2008 Iurii Kiyan
CppUnit
                 Introduction
●
 JUnit port of Michael Feathers
●
 Jerome Lacoste provided port for Unix/Solaris




                                          © 2007­2008 Iurii Kiyan
CppUnit
Base Classes




               © 2007­2008 Iurii Kiyan
CppUnit
                      Simplest unit­test
#include <cppunit/TestCase.h>

class MyTest : public CppUnit::TestCase 
{ 
  public: 
     MyTest( )  : CppUnit::TestCase( “MyTest” ) {}
  
     void runTest() 
     {
        CPPUNIT_ASSERT( Complex (10, 1) == Complex (10, 1) );
        CPPUNIT_ASSERT( !(Complex (1, 1) == Complex (2, 2)) );
    }
};
                                                                 © 2007­2008 Iurii Kiyan
CppUnit
              Simplest unit­test running
#include <cppunit/TestCase.h>
#include <cppunit/TextTestRunner.h>

class MyTest : public CppUnit::TestCase { /* ... */ }

MyTest t;
CppUnit::TextTestRunner r;
r.addTest(&t);
r.run( quot;quot;, true );




                                                        © 2007­2008 Iurii Kiyan
CppUnit
                               Test Fixture
Specialized class which allows to:
1. have called special methods before and after every test
2. have several tests defined in the same class as public methods with 
signature:
         void method()

class SomeTest : public CppUnit::TestFixture 
{
  public:
    void virtual setUp(){ /* initialization of required members */  }
    void virtual tearDown(){ /* cleanup of required members */ }
};
                                                                        © 2007­2008 Iurii Kiyan
CppUnit
                                                     Suite
Specialized class to group tests and run them as a single unit (collection 
for classes which implements Test interface).

CppUnit::TestSuite suite;
suite.addTest(new CppUnit::TestCaller<MyTest>(quot;test1quot;,
                                                                                 &MyTest::test1 ) );
suite.addTest( new CppUnit::TestCaller<MyTest>(quot;testAdditionquot;, 
                                                                                 &MyTest::test2 ) );
CppUnit::TestResult result;
suite.run( &result );


Usefull to have specialized static method in test classes “Suite suite()” 
which contains code for Suite creation.
                                                                                                       © 2007­2008 Iurii Kiyan
CppUnit
                            TestRunner
Tool to run tests and display test results.



int main( int argc, char **argv)
{
  CppUnit::TextUi::TestRunner runner;
  runner.addTest( MyTests1::suite() );
  runner.addTest( MyTests2::suite() );
  runner.run();
  return 0;
}


                                              © 2007­2008 Iurii Kiyan
CppUnit
                         Helper Macros
Minimize coding errors by hiding tests creation into macros.

#include <cppunit/extensions/HelperMacros.h>

class SampleTest : public CppUnit::TestFixture  
{
    CPPUNIT_TEST_SUITE( SampleTest );
    CPPUNIT_TEST( test1 );
    CPPUNIT_TEST_SUITE_END();
public:
    void setUp()  { /*...*/ }
    void tearDown()  { /* ... */ }
    void test1() { /* ... */ }
};
                                                          © 2007­2008 Iurii Kiyan
CppUnit
                    TestFactoryRegistry
Allows to simplify running all test (creates collection of test classes).

#include <cppunit/extensions/HelperMacros.h>
CPPUNIT_TEST_SUITE_REGISTRATION( MyTest );//for every testset

int main( int argc, char **argv)
{
     CppUnit::TextUi::TestRunner runner;
     CppUnit::TestFactoryRegistry &registry =
                            CppUnit::TestFactoryRegistry::getRegistry();
     runner.addTest( registry.makeTest() );
     runner.run();
     return 0;
};
                                                                            © 2007­2008 Iurii Kiyan
CppUnit
           Integration in build process
int main( int argc, char **argv)
{
     CppUnit::TextUi::TestRunner runner;
     CppUnit::TestFactoryRegistry &registry =
                            CppUnit::TestFactoryRegistry::getRegistry();
     runner.addTest( registry.makeTest() );
     bool wasSuccessful = runner.run( quot;quot;, false );
     return !wasSuccessful;
};




                                                                     © 2007­2008 Iurii Kiyan
CppUnit
                 References


1. http://cppunit.sourceforge.net/
2. http://sourceforge.net/projects/cppunit




                                        © 2007­2008 Iurii Kiyan

Más contenido relacionado

La actualidad más candente

C++ Unit testing - the good, the bad & the ugly
C++ Unit testing - the good, the bad & the uglyC++ Unit testing - the good, the bad & the ugly
C++ Unit testing - the good, the bad & the uglyDror Helper
 
Continuous Integration (Jenkins/Hudson)
Continuous Integration (Jenkins/Hudson)Continuous Integration (Jenkins/Hudson)
Continuous Integration (Jenkins/Hudson)Dennys Hsieh
 
Robot framework
Robot frameworkRobot framework
Robot frameworkboriau
 
Network Automation (NetDevOps) with Ansible
Network Automation (NetDevOps) with AnsibleNetwork Automation (NetDevOps) with Ansible
Network Automation (NetDevOps) with AnsibleAPNIC
 
JMockit Framework Overview
JMockit Framework OverviewJMockit Framework Overview
JMockit Framework OverviewMario Peshev
 
TestNG introduction
TestNG introductionTestNG introduction
TestNG introductionDenis Bazhin
 
Unit Testing with xUnit.net - Part 2
Unit Testing with xUnit.net - Part 2Unit Testing with xUnit.net - Part 2
Unit Testing with xUnit.net - Part 2BizTalk360
 
Introduction to K6
Introduction to K6Introduction to K6
Introduction to K6Knoldus Inc.
 
katalon studio 툴을 이용한 GUI 테스트 자동화 가이드
katalon studio 툴을 이용한 GUI 테스트 자동화 가이드katalon studio 툴을 이용한 GUI 테스트 자동화 가이드
katalon studio 툴을 이용한 GUI 테스트 자동화 가이드SangIn Choung
 
What Linux can learn from Solaris performance and vice-versa
What Linux can learn from Solaris performance and vice-versaWhat Linux can learn from Solaris performance and vice-versa
What Linux can learn from Solaris performance and vice-versaBrendan Gregg
 
Introduction to Apache ActiveMQ Artemis
Introduction to Apache ActiveMQ ArtemisIntroduction to Apache ActiveMQ Artemis
Introduction to Apache ActiveMQ ArtemisYoshimasa Tanabe
 

La actualidad más candente (20)

C++ Unit testing - the good, the bad & the ugly
C++ Unit testing - the good, the bad & the uglyC++ Unit testing - the good, the bad & the ugly
C++ Unit testing - the good, the bad & the ugly
 
TestNG
TestNGTestNG
TestNG
 
Continuous Integration (Jenkins/Hudson)
Continuous Integration (Jenkins/Hudson)Continuous Integration (Jenkins/Hudson)
Continuous Integration (Jenkins/Hudson)
 
Unit testing with JUnit
Unit testing with JUnitUnit testing with JUnit
Unit testing with JUnit
 
Robot framework
Robot frameworkRobot framework
Robot framework
 
JUNit Presentation
JUNit PresentationJUNit Presentation
JUNit Presentation
 
Network Automation (NetDevOps) with Ansible
Network Automation (NetDevOps) with AnsibleNetwork Automation (NetDevOps) with Ansible
Network Automation (NetDevOps) with Ansible
 
JMockit Framework Overview
JMockit Framework OverviewJMockit Framework Overview
JMockit Framework Overview
 
TestNG introduction
TestNG introductionTestNG introduction
TestNG introduction
 
Unit Testing with xUnit.net - Part 2
Unit Testing with xUnit.net - Part 2Unit Testing with xUnit.net - Part 2
Unit Testing with xUnit.net - Part 2
 
Introduction to K6
Introduction to K6Introduction to K6
Introduction to K6
 
JUnit Presentation
JUnit PresentationJUnit Presentation
JUnit Presentation
 
Java Unit Testing
Java Unit TestingJava Unit Testing
Java Unit Testing
 
katalon studio 툴을 이용한 GUI 테스트 자동화 가이드
katalon studio 툴을 이용한 GUI 테스트 자동화 가이드katalon studio 툴을 이용한 GUI 테스트 자동화 가이드
katalon studio 툴을 이용한 GUI 테스트 자동화 가이드
 
Robot framework
Robot frameworkRobot framework
Robot framework
 
What Linux can learn from Solaris performance and vice-versa
What Linux can learn from Solaris performance and vice-versaWhat Linux can learn from Solaris performance and vice-versa
What Linux can learn from Solaris performance and vice-versa
 
Hybrid framework
Hybrid frameworkHybrid framework
Hybrid framework
 
TestNG with selenium
TestNG with seleniumTestNG with selenium
TestNG with selenium
 
Introduction to Apache ActiveMQ Artemis
Introduction to Apache ActiveMQ ArtemisIntroduction to Apache ActiveMQ Artemis
Introduction to Apache ActiveMQ Artemis
 
Introduction to JUnit
Introduction to JUnitIntroduction to JUnit
Introduction to JUnit
 

Destacado

Nunit C# source code defects report by Parasoft dotTEST
Nunit  C# source code  defects report by Parasoft dotTEST Nunit  C# source code  defects report by Parasoft dotTEST
Nunit C# source code defects report by Parasoft dotTEST Engineering Software Lab
 
Parasoft Concerto A complete ALM platform that ensures quality software can b...
Parasoft Concerto A complete ALM platform that ensures quality software can b...Parasoft Concerto A complete ALM platform that ensures quality software can b...
Parasoft Concerto A complete ALM platform that ensures quality software can b...Engineering Software Lab
 
Amran Tuberi - the damage of cycling to the desert ecosystem
Amran Tuberi - the damage of cycling to the desert ecosystemAmran Tuberi - the damage of cycling to the desert ecosystem
Amran Tuberi - the damage of cycling to the desert ecosystemEngineering Software Lab
 
Perforce עשרת היתרונות המובילים של מערכת ניהול התצורה
Perforce עשרת היתרונות המובילים של מערכת ניהול התצורהPerforce עשרת היתרונות המובילים של מערכת ניהול התצורה
Perforce עשרת היתרונות המובילים של מערכת ניהול התצורהEngineering Software Lab
 
Parasoft .TEST, Write better C# Code Using Data Flow Analysis
Parasoft .TEST, Write better C# Code Using  Data Flow Analysis Parasoft .TEST, Write better C# Code Using  Data Flow Analysis
Parasoft .TEST, Write better C# Code Using Data Flow Analysis Engineering Software Lab
 
WPF/ XamDataGrid Performance, Infragistics Seminar, Israel , November 2011
WPF/ XamDataGrid Performance, Infragistics Seminar, Israel , November 2011WPF/ XamDataGrid Performance, Infragistics Seminar, Israel , November 2011
WPF/ XamDataGrid Performance, Infragistics Seminar, Israel , November 2011Engineering Software Lab
 
Code coverage in theory and in practice form the do178 b perspective
Code coverage in theory and in practice form the do178 b perspectiveCode coverage in theory and in practice form the do178 b perspective
Code coverage in theory and in practice form the do178 b perspectiveEngineering Software Lab
 
Code Coverage in Theory and in practice form the DO178B perspective
Code Coverage in Theory and in practice form the DO178B perspective   Code Coverage in Theory and in practice form the DO178B perspective
Code Coverage in Theory and in practice form the DO178B perspective Engineering Software Lab
 
Automation Testing with TestComplete
Automation Testing with TestCompleteAutomation Testing with TestComplete
Automation Testing with TestCompleteRomSoft SRL
 
Script Driven Testing using TestComplete
Script Driven Testing using TestCompleteScript Driven Testing using TestComplete
Script Driven Testing using TestCompletesrivinayak
 
Automated Python Test Frameworks for Hardware Verification and Validation
Automated Python Test Frameworks for Hardware Verification and ValidationAutomated Python Test Frameworks for Hardware Verification and Validation
Automated Python Test Frameworks for Hardware Verification and ValidationBarbara Jones
 

Destacado (20)

Embedded System Test Automation
Embedded System Test AutomationEmbedded System Test Automation
Embedded System Test Automation
 
Nunit C# source code defects report by Parasoft dotTEST
Nunit  C# source code  defects report by Parasoft dotTEST Nunit  C# source code  defects report by Parasoft dotTEST
Nunit C# source code defects report by Parasoft dotTEST
 
Parasoft Concerto A complete ALM platform that ensures quality software can b...
Parasoft Concerto A complete ALM platform that ensures quality software can b...Parasoft Concerto A complete ALM platform that ensures quality software can b...
Parasoft Concerto A complete ALM platform that ensures quality software can b...
 
Amran Tuberi - the damage of cycling to the desert ecosystem
Amran Tuberi - the damage of cycling to the desert ecosystemAmran Tuberi - the damage of cycling to the desert ecosystem
Amran Tuberi - the damage of cycling to the desert ecosystem
 
Parasoft fda software compliance part2
Parasoft fda software compliance   part2Parasoft fda software compliance   part2
Parasoft fda software compliance part2
 
Perforce עשרת היתרונות המובילים של מערכת ניהול התצורה
Perforce עשרת היתרונות המובילים של מערכת ניהול התצורהPerforce עשרת היתרונות המובילים של מערכת ניהול התצורה
Perforce עשרת היתרונות המובילים של מערכת ניהול התצורה
 
Parasoft fda software compliance part1
Parasoft fda software compliance   part1Parasoft fda software compliance   part1
Parasoft fda software compliance part1
 
Parasoft .TEST, Write better C# Code Using Data Flow Analysis
Parasoft .TEST, Write better C# Code Using  Data Flow Analysis Parasoft .TEST, Write better C# Code Using  Data Flow Analysis
Parasoft .TEST, Write better C# Code Using Data Flow Analysis
 
Introduction to Parasoft C++TEST
Introduction to Parasoft C++TEST Introduction to Parasoft C++TEST
Introduction to Parasoft C++TEST
 
המסדרת הפכה למגוהצת
המסדרת הפכה למגוהצתהמסדרת הפכה למגוהצת
המסדרת הפכה למגוהצת
 
A Scalable Software Build Accelerator
A Scalable Software Build AcceleratorA Scalable Software Build Accelerator
A Scalable Software Build Accelerator
 
WPF/ XamDataGrid Performance, Infragistics Seminar, Israel , November 2011
WPF/ XamDataGrid Performance, Infragistics Seminar, Israel , November 2011WPF/ XamDataGrid Performance, Infragistics Seminar, Israel , November 2011
WPF/ XamDataGrid Performance, Infragistics Seminar, Israel , November 2011
 
Palamida Open Source Compliance Solution
Palamida Open Source Compliance Solution Palamida Open Source Compliance Solution
Palamida Open Source Compliance Solution
 
Code coverage in theory and in practice form the do178 b perspective
Code coverage in theory and in practice form the do178 b perspectiveCode coverage in theory and in practice form the do178 b perspective
Code coverage in theory and in practice form the do178 b perspective
 
FDA software compliance 2016
FDA software compliance 2016FDA software compliance 2016
FDA software compliance 2016
 
Code Coverage in Theory and in practice form the DO178B perspective
Code Coverage in Theory and in practice form the DO178B perspective   Code Coverage in Theory and in practice form the DO178B perspective
Code Coverage in Theory and in practice form the DO178B perspective
 
Automation Testing with TestComplete
Automation Testing with TestCompleteAutomation Testing with TestComplete
Automation Testing with TestComplete
 
Script Driven Testing using TestComplete
Script Driven Testing using TestCompleteScript Driven Testing using TestComplete
Script Driven Testing using TestComplete
 
Test Complete
Test CompleteTest Complete
Test Complete
 
Automated Python Test Frameworks for Hardware Verification and Validation
Automated Python Test Frameworks for Hardware Verification and ValidationAutomated Python Test Frameworks for Hardware Verification and Validation
Automated Python Test Frameworks for Hardware Verification and Validation
 

Similar a CppUnit using introduction

Introduction to Unit Testing with PHPUnit
Introduction to Unit Testing with PHPUnitIntroduction to Unit Testing with PHPUnit
Introduction to Unit Testing with PHPUnitMichelangelo van Dam
 
Google C++ Testing Framework in Visual Studio 2008
Google C++ Testing Framework in Visual Studio 2008Google C++ Testing Framework in Visual Studio 2008
Google C++ Testing Framework in Visual Studio 2008Andrea Francia
 
Junit4&testng presentation
Junit4&testng presentationJunit4&testng presentation
Junit4&testng presentationSanjib Dhar
 
Testing with JUnit 5 and Spring
Testing with JUnit 5 and SpringTesting with JUnit 5 and Spring
Testing with JUnit 5 and SpringVMware Tanzu
 
J unit presentation
J unit presentationJ unit presentation
J unit presentationPriya Sharma
 
Automated Unit Testing
Automated Unit TestingAutomated Unit Testing
Automated Unit TestingMike Lively
 
Webtests Reloaded - Webtest with Selenium, TestNG, Groovy and Maven
Webtests Reloaded - Webtest with Selenium, TestNG, Groovy and MavenWebtests Reloaded - Webtest with Selenium, TestNG, Groovy and Maven
Webtests Reloaded - Webtest with Selenium, TestNG, Groovy and MavenThorsten Kamann
 
API Performance Testing
API Performance TestingAPI Performance Testing
API Performance Testingrsg00usa
 
Verify Your Kubernetes Clusters with Upstream e2e tests
Verify Your Kubernetes Clusters with Upstream e2e testsVerify Your Kubernetes Clusters with Upstream e2e tests
Verify Your Kubernetes Clusters with Upstream e2e testsKen'ichi Ohmichi
 
Testing basics for developers
Testing basics for developersTesting basics for developers
Testing basics for developersAnton Udovychenko
 
单元测试必知必会
单元测试必知必会单元测试必知必会
单元测试必知必会智杰 付
 

Similar a CppUnit using introduction (20)

guice-servlet
guice-servletguice-servlet
guice-servlet
 
Junit
JunitJunit
Junit
 
Introduction to Unit Testing with PHPUnit
Introduction to Unit Testing with PHPUnitIntroduction to Unit Testing with PHPUnit
Introduction to Unit Testing with PHPUnit
 
PHPUnit testing to Zend_Test
PHPUnit testing to Zend_TestPHPUnit testing to Zend_Test
PHPUnit testing to Zend_Test
 
Test Automation Using Googletest
Test Automation Using GoogletestTest Automation Using Googletest
Test Automation Using Googletest
 
L08 Unit Testing
L08 Unit TestingL08 Unit Testing
L08 Unit Testing
 
Javascript Unit Testing
Javascript Unit TestingJavascript Unit Testing
Javascript Unit Testing
 
Canoo Show En
Canoo Show EnCanoo Show En
Canoo Show En
 
Unit testing
Unit testingUnit testing
Unit testing
 
Google C++ Testing Framework in Visual Studio 2008
Google C++ Testing Framework in Visual Studio 2008Google C++ Testing Framework in Visual Studio 2008
Google C++ Testing Framework in Visual Studio 2008
 
Junit4&testng presentation
Junit4&testng presentationJunit4&testng presentation
Junit4&testng presentation
 
Testing with JUnit 5 and Spring
Testing with JUnit 5 and SpringTesting with JUnit 5 and Spring
Testing with JUnit 5 and Spring
 
J unit presentation
J unit presentationJ unit presentation
J unit presentation
 
Automated Unit Testing
Automated Unit TestingAutomated Unit Testing
Automated Unit Testing
 
Webtests Reloaded - Webtest with Selenium, TestNG, Groovy and Maven
Webtests Reloaded - Webtest with Selenium, TestNG, Groovy and MavenWebtests Reloaded - Webtest with Selenium, TestNG, Groovy and Maven
Webtests Reloaded - Webtest with Selenium, TestNG, Groovy and Maven
 
API Performance Testing
API Performance TestingAPI Performance Testing
API Performance Testing
 
Verify Your Kubernetes Clusters with Upstream e2e tests
Verify Your Kubernetes Clusters with Upstream e2e testsVerify Your Kubernetes Clusters with Upstream e2e tests
Verify Your Kubernetes Clusters with Upstream e2e tests
 
3 j unit
3 j unit3 j unit
3 j unit
 
Testing basics for developers
Testing basics for developersTesting basics for developers
Testing basics for developers
 
单元测试必知必会
单元测试必知必会单元测试必知必会
单元测试必知必会
 

Último

Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfSeasiaInfotech2
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 

Último (20)

Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdf
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 

CppUnit using introduction

  • 1. CppUnit CppUnit usage  Workshop © 2007­2008 Iurii Kiyan
  • 2. CppUnit Overview ● Introduction ● Using CppUnit framework classes for unit testing ● TestCase ● TestRunner ● TestFixture ● TestSuite ● Helper Macros ● Integration CppUnit in build process ● References © 2007­2008 Iurii Kiyan
  • 3. CppUnit Introduction ● JUnit port of Michael Feathers ● Jerome Lacoste provided port for Unix/Solaris © 2007­2008 Iurii Kiyan
  • 4. CppUnit Base Classes © 2007­2008 Iurii Kiyan
  • 5. CppUnit Simplest unit­test #include <cppunit/TestCase.h> class MyTest : public CppUnit::TestCase  {    public:       MyTest( )  : CppUnit::TestCase( “MyTest” ) {}         void runTest()       {         CPPUNIT_ASSERT( Complex (10, 1) == Complex (10, 1) );         CPPUNIT_ASSERT( !(Complex (1, 1) == Complex (2, 2)) );     } }; © 2007­2008 Iurii Kiyan
  • 6. CppUnit Simplest unit­test running #include <cppunit/TestCase.h> #include <cppunit/TextTestRunner.h> class MyTest : public CppUnit::TestCase { /* ... */ } MyTest t; CppUnit::TextTestRunner r; r.addTest(&t); r.run( quot;quot;, true ); © 2007­2008 Iurii Kiyan
  • 7. CppUnit Test Fixture Specialized class which allows to: 1. have called special methods before and after every test 2. have several tests defined in the same class as public methods with  signature: void method() class SomeTest : public CppUnit::TestFixture  {   public:     void virtual setUp(){ /* initialization of required members */  }     void virtual tearDown(){ /* cleanup of required members */ } }; © 2007­2008 Iurii Kiyan
  • 8. CppUnit Suite Specialized class to group tests and run them as a single unit (collection  for classes which implements Test interface). CppUnit::TestSuite suite; suite.addTest(new CppUnit::TestCaller<MyTest>(quot;test1quot;,                                                                                  &MyTest::test1 ) ); suite.addTest( new CppUnit::TestCaller<MyTest>(quot;testAdditionquot;,                                                                                   &MyTest::test2 ) ); CppUnit::TestResult result; suite.run( &result ); Usefull to have specialized static method in test classes “Suite suite()”  which contains code for Suite creation. © 2007­2008 Iurii Kiyan
  • 9. CppUnit TestRunner Tool to run tests and display test results. int main( int argc, char **argv) {   CppUnit::TextUi::TestRunner runner;   runner.addTest( MyTests1::suite() );   runner.addTest( MyTests2::suite() );   runner.run();   return 0; } © 2007­2008 Iurii Kiyan
  • 10. CppUnit Helper Macros Minimize coding errors by hiding tests creation into macros. #include <cppunit/extensions/HelperMacros.h> class SampleTest : public CppUnit::TestFixture   { CPPUNIT_TEST_SUITE( SampleTest ); CPPUNIT_TEST( test1 ); CPPUNIT_TEST_SUITE_END(); public: void setUp()  { /*...*/ } void tearDown()  { /* ... */ } void test1() { /* ... */ } }; © 2007­2008 Iurii Kiyan
  • 11. CppUnit TestFactoryRegistry Allows to simplify running all test (creates collection of test classes). #include <cppunit/extensions/HelperMacros.h> CPPUNIT_TEST_SUITE_REGISTRATION( MyTest );//for every testset int main( int argc, char **argv) { CppUnit::TextUi::TestRunner runner; CppUnit::TestFactoryRegistry &registry =  CppUnit::TestFactoryRegistry::getRegistry(); runner.addTest( registry.makeTest() ); runner.run(); return 0; }; © 2007­2008 Iurii Kiyan
  • 12. CppUnit Integration in build process int main( int argc, char **argv) { CppUnit::TextUi::TestRunner runner; CppUnit::TestFactoryRegistry &registry =  CppUnit::TestFactoryRegistry::getRegistry(); runner.addTest( registry.makeTest() ); bool wasSuccessful = runner.run( quot;quot;, false ); return !wasSuccessful; }; © 2007­2008 Iurii Kiyan
  • 13. CppUnit References 1. http://cppunit.sourceforge.net/ 2. http://sourceforge.net/projects/cppunit © 2007­2008 Iurii Kiyan