Christian Hujer What is AceUnit? How does AceUnit work? How do I use AceUnit? 2007-12-161© 2007 Christian Hujer.

Slides:



Advertisements
Similar presentations
Design By Contract Using JMSAssert.
Advertisements

Unit Testing Australian Development Centre Brisbane, Australia.
Java Testing Tools. junit is a testing harness for unit testing. emma is a code coverage tool. The tools can be used in concert to provide statement and.
J-Unit Framework.
MAHDI OMAR JUNIT TUTORIAL. CONTENTS Installation of Junit Eclipse support for Junit Using Junit exercise JUnit options Questions Links and Literature.
T ESTING WITH J UNIT IN E CLIPSE Farzana Rahman. I NTRODUCTION The class that you will want to test is created first so that Eclipse will be able to find.
Ch. 2 Exploring core JUnit. This chapter covers ■ Using the core JUnit classes ■ Understanding JUnit mechanisms ■ Understanding the JUnit lifecycle.
Objectives: Test Options JUnit Testing Framework TestRunners Test Cases and Test Suites Test Fixtures JUnit.
Chapter 15: Discovering problems ● There are some tools that we can use to discover problems – Junit: for unit testing – Ant as a make utility – CVS as.
Approach of Unit testing with the help of JUnit Satish Mishra
Well-behaved objects 4.0 Testing. 2 Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling Main concepts to.
JUnit. What is unit testing? A unit is the smallest testable part of an application. A unit test automatically verifies the correctness of the unit. There.
JUnit, Revisited 17-Apr-17.
Fall 2007CS 2251 Programming Tools Eclipse JUnit Testing make and ant.
JUnit Introduction and Advanced Features. Topics Covered  Junit Introduction  Fixtures  Test Suites  Currency Example.
JUnit. Why is testing good? Due to psychological factors, programmers are bad testers. A computer can test much faster than a human Philosophy: “If it.
Testowanie kodu Bartosz Baliś, Na podstawie prezentacji Satisha Mishra Iana Sommerville Erica Braude.
Presentation Outline What is JUnit? Why Use JUnit? JUnit Features Design of JUnit Downloading JUnit Writing Tests – TestCase – TestSuite Organizing The.
14-Jul-15 JUnit 4. Comparing JUnit 3 to JUnit 4 All the old assertXXX methods are the same Most things are about equally easy JUnit 4 makes it easier.
Programmer Testing Testing all things Java using JUnit and extensions.
Unit Testing & Defensive Programming. F-22 Raptor Fighter.
© Dr. A. Williams, Fall Present Software Quality Assurance – JUnit Lab 1 JUnit A unit test framework for Java –Authors: Erich Gamma, Kent Beck Objective:
Concordia University Department of Computer Science and Software Engineering Click to edit Master title style ADVANCED PROGRAMMING PRACTICES Unit Testing.
JUnit The framework. Goal of the presentation showing the design and construction of JUnit, a piece of software with proven value.
Lecture 6 Software Testing and jUnit CS140 Dick Steflik.
What's New In Progress Developer Studio for OpenEdge?
Computer Science and Engineering College of Engineering The Ohio State University JUnit The credit for these slides goes to Professor Paul Sivilotti at.
JUnit in Action SECOND EDITION PETAR TAHCHIEV FELIPE LEME VINCENT MASSOL GARY GREGORY ©2011 by Manning Publications Co. All rights reserved. Slides Prepared.
Testing in Extreme Programming
Unit and Functional Testing Your Flex Applications Mike Nimer Dir. Of Engineering nomee.com.
|Tecnologie Web L-A Anno Accademico Laboratorio di Tecnologie Web Introduzione ad Eclipse e Tomcat
Unit testing Unit testing TDD with JUnit. Unit Testing Unit testing with JUnit 2 Testing concepts Unit testing Testing tools JUnit Practical use of tools.
CSC 216/001 Lecture 4. Unit Testing  Why is it called “unit” testing?  When should tests be written?  Before the code for a class is written.  After.
1162 JDK 5.0 Features Christian Kemper Principal Architect Borland.
Introduction to Eclipse CSC 216 Lecture 3 Ed Gehringer Using (with permission) slides developed by— Dwight Deugo Nesa Matic
Test automation / JUnit Building automatically repeatable test suites.
Testing in NetBeans. SWC Testing The ideal test: When the test is passed, the product is ready for delivery! Ideal – but (almost) impossible –Number of.
CSC 395 – Software Engineering Lecture 10: Execution-based Testing –or– We can make it better than it was. Better...faster...agiler.
Well-behaved objects Main concepts to be covered Testing Debugging Test automation Writing for maintainability Objects First with Java - A Practical.
Introduction to JUnit 3.8 SEG 3203 Winter ‘07 Prepared By Samia Niamatullah.
Unit Testing with JUnit and Clover Based on material from: Daniel Amyot JUnit Web site.
JUnit Adam Heath. What is JUnit?  JUnit is a unit testing framework for the Java programming language  It allows developers to swiftly and easily test.
A tool for test-driven development
EMBEDDED REAL-TIME, INC. December 8, 2015 Java Unit Mark Mosher Rochester Java Users Group.
JUnit Don Braffitt Updated: 10-Jun-2011.
JUnit A framework which provides hooks for easy testing of your Java code, as it's built Note: The examples from these slides can be found in ~kschmidt/public_html/CS265/Labs/Java/Junit.
JUnit. Introduction JUnit is an open source Java testing framework used to write and run repeatable tests JUnit is integrated with several IDEs, including.
David Streader Computer Science Victoria University of Wellington Copyright: David Streader, Victoria University of Wellington Debugging COMP T1.
Occasion: Date: Present: Classification: Unit testing frameworks for OpenEdge Comparison between ProUnit and OEUnit. ABL Unit in OpenEdge 11.4 Mihai Pintea.
© Spiros Mancoridis Software Engineering (Unit Testing Tools) Dependable Software Systems Topics in Unit Testing Tools Material drawn from [ junit.org,
S Ramakrishnan1 Systems V & V, Quality and Standards Dr Sita Ramakrishnan School CSSE Monash University.
1 CSC 216 Lecture 3. 2 Unit Testing  The most basic kind of testing is called unit testing  Why is it called “unit” testing?  When should tests be.
Test a Little, Code a Little Colin Sharples IBM Global Services New Zealand Colin Sharples IBM Global Services New Zealand.
Classes, Interfaces and Packages
Unit Testing. F-22 Raptor Fighter Manufactured by Lockheed Martin & Boeing How many parts does the F-22 have?
Unit Testing with FlexUnit
Justin Bare and Deric Pang with material from Erin Peach, Nick Carney, Vinod Rathnam, Alex Mariakakis, Krysta Yousoufian, Mike Ernst, Kellen Donohue Section.
1 JUnit. 2 Unit Testing with JUnit If code has no automated test case written for it to prove that it works, it must be assumed not to work. An API that.
Unit Testing in Eclipse Presented by David Eisler 08/09/2014.
Getting Started with JUnit Getting Started with JUnit The benefits and ease of writing and running JUnit test cases and test suites. The benefits and ease.
Unit Testing.
Advanced program design with c++
Software Construction Lab 10 Unit Testing with JUnit
Don Braffitt Updated: 26-Mar-2013
Introduction to JUnit CS 4501 / 6501 Software Testing
An Automated Testing Framework
Introduction to JUnit CS 4501 / 6501 Software Testing
Introduction to JUnit IT323 – Software Engineering II
CS 240 – Advanced Programming Concepts
Plug-In Architecture Pattern
Presentation transcript:

Christian Hujer What is AceUnit? How does AceUnit work? How do I use AceUnit? © 2007 Christian Hujer

What is AceUnit? Why Unit Test? Requirements, Relationship to other Frameworks © 2007 Christian Hujer2

 Find bugs early  Prevent regression  Speedup development  Embrace change / Refactoring  Grey Box Testing © 2007 Christian Hujer

 Easy to use  As close to JUnit 4.x as possible  Highly Configurable and Adoptable  Suits "normal" and embedded development  Logging compatible with JUnit  Low memory consumption and footprint  High degree of convenience © 2007 Christian Hujer

© 2007 Christian Hujer

 Advanced C and Embedded Unit  Unit Test Framework for C (C89 and C99)  Open Source (License: BSD (revised))  Target environment:  Desktop  Embedded  Architecture based on JUnit 4.x:  Uses Annotations  Uses Reflection © 2007 Christian Hujer

 Further Information  AceUnit:  CUnit:  EmbUnit:  JUnit:  Questions? © 2007 Christian Hujer

AceUnit Components AceUnit Framework © 2007 Christian Hujer8

© 2007 Christian Hujer

© 2007 Christian Hujer10 SuiteFixture Runner Logger Assert Tests Data

 Further Information  AceUnit:  Questions? © 2007 Christian Hujer

Writing Tests Using Assertions Integrating AceUnit in your build Configuring AceUnit © 2007 Christian Hujer12

 Annotations  Fixtures  Assertions  Suites  Logging © 2007 Christian Hujer

 Programming Languages: Java, C#  Metadata about members and other accessible elements  Examples (Java): private String key; private String name;  void final Color color); © 2007 Christian Hujer14

Like JUnit 4.x. No in C -> 'A_' instead. Default: #defined as empty macros  A_Test  Test case  A_Before, A_After  Executed before / after each test case  A_BeforeClass, A_AfterClass  Executed at start / end of fixture © 2007 Christian Hujer

 Collection of test cases with same preconditions  Test source = test class = fixture © 2007 Christian Hujer

fooTest.c */ /* fooTest.h generated by AceUnit Generator */ #include "fooTest.h" /** Some test case. */ A_Test void testFoo1() {…} /** Another test case. */ A_Test void testFoo2() {…} © 2007 Christian Hujer

 Verification is done with Assertions  See AceUnit documentation for list  You can define your own Assertions  Pattern: assertXXX(message, params)  #define ACEUNIT_EMBEDDED:  message is ignored  Instead uses line number as uint16_t © 2007 Christian Hujer

/** My test case. */ A_Test void testFoo1() { #define EXPECTED = 42; uint16_t actual = getAnswer(); assertEquals("Expected answer to be 42.", EXPECTED, actual); } © 2007 Christian Hujer

 Test Case Setup / Teardown  Prepare data for / cleanup after each test case  Like setUp() / tearDown() in JUnit 3.x  in JUnit 4.x  Multiple A_Before / A_After possible  Execution order = order in source code © 2007 Christian Hujer

static Foo_t *foo; A_Before void createFoo() { foo = (Foo_t *) malloc(sizeof(Foo_t)); bzero(foo, sizeof(Foo_t)); } A_After void destroyFoo() { free(foo); } © 2007 Christian Hujer

 Prepare data for all tests  Fixture Setup / Teardown  in JUnit 4.x  New in JUnit 4.x / AceUnit  Multiple A_BeforeClass / A_AfterClass possible  Execution order = order in source code © 2007 Christian Hujer

static Foo_t *foo; A_BeforeClass void allocateFoo() { foo = (Foo_t *) malloc(sizeof(Foo_t)); } A_Before void initFoo() { bzero(foo, sizeof(Foo_t)); } A_AfterClass void freeFoo() { free(foo); } © 2007 Christian Hujer

© 2007 Christian Hujer

 A_Test, A_Before etc.  Must be on same line as annotated method  Should be before other modifiers of method  ACEUNIT_STATIC_ANNOTATIONS  Define this to #define annotations static  Pro: No name clashes between fixtures  Con: Problems with some debuggers © 2007 Christian Hujer

 aceunit/src/native  Add to include search path  Add to C search path  Before compilation  Run generator  Include in compilation:  AceUnit.c  AceUnitData.c  Logger of your choice © 2007 Christian Hujer

 ACEUNIT_EMBEDDED  Use AceUnit in embedded mode  less footprint  uint16_t instead of char*  ACEUNIT_C99  Use AceUnit with C99 instead of C89/C90.  ACEUNIT_STATIC_ANNOTATIONS  #define A_* static © 2007 Christian Hujer

 ACEUNIT_CODE_INCLUDE  Define file to include for code (ROM).  Use for section information.  ACEUNIT_DATA_INCLUDE  Define a file to include before variables (RAM).  Use for section information © 2007 Christian Hujer28

 ACEUNIT_ASSERTION_STYLE  Define how to "implement" fail  Possible values: ▪ ACEUNIT_ASSERTION_STYLE_RETURN ▪ ACEUNIT_ASSERTION_STYLE_ASSERT ▪ ACEUNIT_ASSERTION_STYLE_ABORT ▪ ACEUNIT_ASSERTION_STYLE_LONGJMP ▪ ACEUNIT_ASSERTION_STYLE_CUSTOM ▪ -> Define ACEUNIT_CUSTOM_ASSERT() © 2007 Christian Hujer29

 Small Java Program  Creates headers for fixtures  "Connects" your fixtures with AceUnit  Requires JRE 1.5 or newer © 2007 Christian Hujer30

 Arguments:  List of Suite names ▪ Packages (directories, will be searched recursively) ▪ Fixtures (omit.c suffix!)  Options:  --exit Quit Java VM with error code. (Use!)  -h, --help: Display help and exit.  -f, --force: Overwrite write-protected files © 2007 Christian Hujer31

 Example (in a Makefile): prepareAceUnit: java -jar AceUnit.jar --exit src/  Example (Batch): java -jar AceUnit.jar --exit src/ && cc $(find –name *.c) -o runTests &&./runTests © 2007 Christian Hujer32

 Questions? © 2007 Christian Hujer33

Footprint, Future Unit Tests in Software Engineering © 2007 Christian Hujer34

In bytes for 32 Bit with ACEUNIT_EMBEDDED  Code (constant data, anywhere)  4 per annotated methods  48 per Fixture  2 per test case  Plus code (testling and fixture)  Data (variable data, RAM)  16 for Runner  N*2 for Logging (MiniRamLogger, N = log failures)  1 Jump Buffer (if setjmp()/longjmp() is used) © 2007 Christian Hujer

 5 Fixtures with 40 methods, 30 test cases  Code:  4 * * * 30 plus code  = 460 plus code  Data (5 failure entries):  * 2 + Jump Buffer  = 26 + Jump Buffer © 2007 Christian Hujer

 Generator  Ant Task for Java Generator (Q1 2008)  Alternative Perl Generator (Q1 2008)  Alternative C Generator (?)  Framework  More Assertions (Q1 2008)  Internal Refactoring (encapsulation, public API) (?)  Pluggable Runners (Q2 2008)  Support of Suites (Q2 2008) © 2007 Christian Hujer37

© 2007 Christian Hujer38

 Thanks for Listening!  Questions? © 2007 Christian Hujer39