Occasion: Date: Present: Classification: Unit testing frameworks for OpenEdge Comparison between...

18
Occasion: Date: Present: Classification : Unit testing frameworks for OpenEdge Comparison between ProUnit and OEUnit. ABL Unit in OpenEdge 11.4 Mihai Pintea [email protected]

Transcript of Occasion: Date: Present: Classification: Unit testing frameworks for OpenEdge Comparison between...

Page 1: Occasion: Date: Present: Classification: Unit testing frameworks for OpenEdge Comparison between ProUnit and OEUnit. ABL Unit in OpenEdge 11.4 Mihai Pintea.

Occasion:Date:

Present:Classification:

Unit testing frameworks for OpenEdge

Comparison between ProUnit and OEUnit.ABL Unit in OpenEdge 11.4

Mihai [email protected]

Page 2: Occasion: Date: Present: Classification: Unit testing frameworks for OpenEdge Comparison between ProUnit and OEUnit. ABL Unit in OpenEdge 11.4 Mihai Pintea.

2

Agenda

ProUnit vs

OEUnit

ABLUnit starting 11.4

What is Unit

testing

Page 3: Occasion: Date: Present: Classification: Unit testing frameworks for OpenEdge Comparison between ProUnit and OEUnit. ABL Unit in OpenEdge 11.4 Mihai Pintea.

3

Traditional Development Life

Development

Test

Delivery

Testers write the test

Fail

Page 4: Occasion: Date: Present: Classification: Unit testing frameworks for OpenEdge Comparison between ProUnit and OEUnit. ABL Unit in OpenEdge 11.4 Mihai Pintea.

4

Unit Testing

● Unit testing is a method by which individual units of source code, sets of one or more computer program modules together with associated control data, usage procedures, and operating procedures are tested to determine if they are fit for use.

● Tests written by Developers.● Test run as integral part of Development

Benefits of Unit Testing● Find problems early● Easier to locate bugs● Facilitate change● Document units● Writing tests clarifies design

Page 5: Occasion: Date: Present: Classification: Unit testing frameworks for OpenEdge Comparison between ProUnit and OEUnit. ABL Unit in OpenEdge 11.4 Mihai Pintea.

5

Unit Testing Considerations

● Time consuming and expensive● Not practical to test everything● Extra code to maintain, however:

• Tests often are small• Payback: need to do some changes quickly

● Needs team adoption• Need to be able to trust the tests

● Needs a unit testing Framework

Page 6: Occasion: Date: Present: Classification: Unit testing frameworks for OpenEdge Comparison between ProUnit and OEUnit. ABL Unit in OpenEdge 11.4 Mihai Pintea.

6

Initial Unit Test Frameworks for OpenEdge

Unit test

frameworks

ProUnit

OEUnit

Page 7: Occasion: Date: Present: Classification: Unit testing frameworks for OpenEdge Comparison between ProUnit and OEUnit. ABL Unit in OpenEdge 11.4 Mihai Pintea.

7

Installing ProUnit and OEUnit

ProUnit installation:● http://

prounit.sourceforge.net● uncompressing the file in

a directory of your choice● add full path to

prounit_dlcXX.pl to the PROPATH

● in case of client/AppServer usage, you should add prounit_dlcXX.pl to PROPATH for both client and AppServer

OEUnit installation:● https://

github.com/CameronWills/OEUnit

● Uncompressing the file in a directory of your choice

● Add an entry to PROPATH pointing to the \src

● Add the -errorstack startup parameter

Page 8: Occasion: Date: Present: Classification: Unit testing frameworks for OpenEdge Comparison between ProUnit and OEUnit. ABL Unit in OpenEdge 11.4 Mihai Pintea.

8

Running ProUnit and OEUnit

Running ProUnit:● run startProUnitGUI.p.

Running OEUnit● Add a Menu Action to OpenEdge

Architect

● right-click to open the context menu from the ABL Editor

Page 9: Occasion: Date: Present: Classification: Unit testing frameworks for OpenEdge Comparison between ProUnit and OEUnit. ABL Unit in OpenEdge 11.4 Mihai Pintea.

9

Writing a Test Case

ProUnit:● A Test Case is just a

Progress ABL (4GL) file that follows some simple rules about how to name the internal procedures

● Example simpletest.p

OEUnit:● A test case is a class

containing one or more Test methods.

Example:ROUTINE-LEVEL ON ERROR UNDO, THROW.USING OEUnit.Assertion.Assert. CLASS SimpleTest: @Test. METHOD PUBLIC VOID IntegerTest(): DEFINE VARIABLE myInt AS INTEGER NO-UNDO. Assert:AreEqual(myInt,0). END METHOD. END CLASS.

PROCEDURE testSimpleTest:DEFINE VARIABLE myInt AS INTEGER NO-UNDO. RUN assertEqualsInt(myInt,0).END.

Page 10: Occasion: Date: Present: Classification: Unit testing frameworks for OpenEdge Comparison between ProUnit and OEUnit. ABL Unit in OpenEdge 11.4 Mihai Pintea.

10

Writing a Test Suite

ProUnit:● ProUnit lets you arrange

your tests using Test Sets.

OEUnit:● A test suite is a class that

contains a list of test cases and/or other test suites. Test suites are useful for grouping and organizing test cases.

Example:

ROUTINE-LEVEL ON ERROR UNDO, THROW. CLASS SimpleSuite INHERITS OEUnit.Runner.TestSuite: CONSTRUCTOR SimpleSuite(): AddTest(NEW SimpleTest()). AddTest(NEW SimpleTest1()). END CONSTRUCTOR. END CLASS.

Page 11: Occasion: Date: Present: Classification: Unit testing frameworks for OpenEdge Comparison between ProUnit and OEUnit. ABL Unit in OpenEdge 11.4 Mihai Pintea.

11

ProUnit saving results

● ProUnit provides a very extensible and customizablereport engine based on XML and XSLT that make it possible to change completely the report format (adding logos, changing fonts, etc), create multiple styles or savingplain XML files to be imported into a database.

● ProUnit allow you to save results in many forms:• XML with SLST• JUnit XML• CSV file• Plain text file with indentation

Page 12: Occasion: Date: Present: Classification: Unit testing frameworks for OpenEdge Comparison between ProUnit and OEUnit. ABL Unit in OpenEdge 11.4 Mihai Pintea.

12

ABLUnit

ABLUnit

Page 13: Occasion: Date: Present: Classification: Unit testing frameworks for OpenEdge Comparison between ProUnit and OEUnit. ABL Unit in OpenEdge 11.4 Mihai Pintea.

13

ABL Unit Framework

● ABLUnit is a simple yet powerful unit testing framework for testing ABL programs.

● ABLUnit is similar with OEUnit

● No installation needed because is integrated on OpenEdge 11.4

● Run in OpenEdge ABLUnit perspective

Page 14: Occasion: Date: Present: Classification: Unit testing frameworks for OpenEdge Comparison between ProUnit and OEUnit. ABL Unit in OpenEdge 11.4 Mihai Pintea.

14

ABLUnit test case

ABLUnit:● Similar with OEUnit, a test case is a class containing

one or more Test methods.ABLUnit: OEUnit:

ROUTINE-LEVEL ON ERROR UNDO, THROW.USING Progress.Lang.*.USING OpenEdge.Core.Assert.

CLASS SimpleTest: @Test. METHOD PUBLIC VOID IntegerTest(): DEFINE VARIABLE myInt AS INTEGER NO-UNDO. Assert:equals(myInt,0). END METHOD. END CLASS.

ROUTINE-LEVEL ON ERROR UNDO, THROW.

USING OEUnit.Assertion.Assert.

CLASS SimpleTest: @Test. METHOD PUBLIC VOID IntegerTest(): DEFINE VARIABLE myInt AS INTEGER NO-UNDO. Assert:AreEqual(myInt,0). END METHOD. END CLASS.

Page 15: Occasion: Date: Present: Classification: Unit testing frameworks for OpenEdge Comparison between ProUnit and OEUnit. ABL Unit in OpenEdge 11.4 Mihai Pintea.

15

ABLUnit vs OEUnit vs ProUnit

ABLUnit OEUnit ProUnit

File type support

Supports class and procedure

Supports only class Supports only procedure

Annotations Required:-        Before-        Setup-        Test-        TearDown-        Ignore-        After

Required:-        BeforeClass-        Before-        After-        Test-        Ignore-        AfterClass

Doesn’t require annotations. -        Initialize-        setup       test<Name>-        teardown-        dispose

Nightly Builds

Yes (Provided ANT task)

- Can be used with PCT ANT Task

GUI PDS OE Can be embedded into PDSOE

Desktop App

Command Line

Yes No Yes

Page 16: Occasion: Date: Present: Classification: Unit testing frameworks for OpenEdge Comparison between ProUnit and OEUnit. ABL Unit in OpenEdge 11.4 Mihai Pintea.

16

ABLUnit vs OEUnit vs ProUnit

ABLUnit OEUnit ProUnit

Results Separate view is provided.- Navigate to failures- Rerun tests- View history of last 10 results- View only failures- Go to test code

Pluggable view is provided to show unit test.

Summary in tree structure provided

Import results

Imported by ABLUnit, JUnit, Jenkins

No option available to import

No option available to import

Export results

No custom export options.

No export option - XML with SLST- JUnit XML- CSV file- Plain text file with indentation

Page 17: Occasion: Date: Present: Classification: Unit testing frameworks for OpenEdge Comparison between ProUnit and OEUnit. ABL Unit in OpenEdge 11.4 Mihai Pintea.

17

Conclusions

● Benefits of using unit test: find problems early, easier to locate bugs, writing tests clarifies design.

● Unit tests considerations: time consuming and expensive, extra code to maintain, needs team adoption, needs a unit testing Framework

● Unit testing for Open Edge:• ProUnit is helpful when creating

unit tests for procedural applications

• OEUnit is very helpful when creating unit tests for OOP applications

• ABLUnit built in unit testing framework starting progress 11.4

Page 18: Occasion: Date: Present: Classification: Unit testing frameworks for OpenEdge Comparison between ProUnit and OEUnit. ABL Unit in OpenEdge 11.4 Mihai Pintea.

18

Q&A

Q&A