1 trex paul baker 1, dominic evans 1, jens grabowski 2, helmut neukirchen 2, benjamin zeiss 2 the...

27
1 TRex Paul Baker 1 , Dominic Evans 1 , Jens Grabowski 2 , Helmut Neukirchen 2 , Benjamin Zeiss 2 The Refactoring and Metrics Tool for TTCN-3 Test Specifications 1 Motorola Labs, Viables Industrial Estate, Basingstoke, UK 2 Software Engineering for Distributed Systems Group, University of Göttingen Presented by Rob Thomson 1

Upload: bertina-morton

Post on 12-Jan-2016

215 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 1 TRex Paul Baker 1, Dominic Evans 1, Jens Grabowski 2, Helmut Neukirchen 2, Benjamin Zeiss 2 The Refactoring and Metrics Tool for TTCN-3 Test Specifications

1

TRex

Paul Baker1, Dominic Evans1, Jens Grabowski2, Helmut Neukirchen2, Benjamin Zeiss2

The Refactoring and Metrics Toolfor TTCN-3 Test Specifications

1Motorola Labs, Viables Industrial Estate, Basingstoke, UK

2Software Engineering for Distributed Systems Group,University of Göttingen

Presented by Rob Thomson1

Page 2: 1 TRex Paul Baker 1, Dominic Evans 1, Jens Grabowski 2, Helmut Neukirchen 2, Benjamin Zeiss 2 The Refactoring and Metrics Tool for TTCN-3 Test Specifications

2

TTCN-3

• Testing and Test Control Notation– Test specification and test implementation

language– Standardised by ETSI and the ITU

• Originally for functional black-box testing of telecoms systems. Now also for– Internet protocols– Automotive– Aerospace– …

Page 3: 1 TRex Paul Baker 1, Dominic Evans 1, Jens Grabowski 2, Helmut Neukirchen 2, Benjamin Zeiss 2 The Refactoring and Metrics Tool for TTCN-3 Test Specifications

3

Outline

• Motivation

• Metrics

• Refactoring

• TRex Tool

• Summary / Outlook

Page 4: 1 TRex Paul Baker 1, Dominic Evans 1, Jens Grabowski 2, Helmut Neukirchen 2, Benjamin Zeiss 2 The Refactoring and Metrics Tool for TTCN-3 Test Specifications

4

Motivation

• Migration of legacy test suites at Motorola:– Automatic Conversion of tests for a UMTS based

component– 60,000 lines of code– Hard to read, hard to (re-)use, and hard to maintain

• Current tools:– IDE functionality (editing, outline, etc.)– Compiler– Test-Management– But: No support for improving test suites!

Page 5: 1 TRex Paul Baker 1, Dominic Evans 1, Jens Grabowski 2, Helmut Neukirchen 2, Benjamin Zeiss 2 The Refactoring and Metrics Tool for TTCN-3 Test Specifications

5

Approach

• Initial aims:– Assessment of test suites with respect to

lessons learnt from experience– Issue detection– Test suite restructuring

• Assessment and restructuring in TRex using– Metrics– Automated Refactorings

Page 6: 1 TRex Paul Baker 1, Dominic Evans 1, Jens Grabowski 2, Helmut Neukirchen 2, Benjamin Zeiss 2 The Refactoring and Metrics Tool for TTCN-3 Test Specifications

6

Outline

• Motivation

• Metrics

• Refactoring

• TRex Tool

• Summary / Outlook

Page 7: 1 TRex Paul Baker 1, Dominic Evans 1, Jens Grabowski 2, Helmut Neukirchen 2, Benjamin Zeiss 2 The Refactoring and Metrics Tool for TTCN-3 Test Specifications

7

TTCN-3 Metrics (1/2)

• Quantitative measures of a software product– Deliver hints about possible quality issues in test suites

• TTCN-3 metrics:– Number of non-commented lines of TTCN-3 source code– Number of and references to

• Test cases

• Functions

• Altsteps

• Component, data and port types

• Template definitions

• Parameterized templates

Page 8: 1 TRex Paul Baker 1, Dominic Evans 1, Jens Grabowski 2, Helmut Neukirchen 2, Benjamin Zeiss 2 The Refactoring and Metrics Tool for TTCN-3 Test Specifications

8

TTCN-3 Metrics (2/2)

• Template Coupling:– Measures the coupling between data description

and test behavior

Page 9: 1 TRex Paul Baker 1, Dominic Evans 1, Jens Grabowski 2, Helmut Neukirchen 2, Benjamin Zeiss 2 The Refactoring and Metrics Tool for TTCN-3 Test Specifications

9

Outline

• Motivation

• Metrics

• Refactoring

• TRex Tool

• Summary / Outlook

Page 10: 1 TRex Paul Baker 1, Dominic Evans 1, Jens Grabowski 2, Helmut Neukirchen 2, Benjamin Zeiss 2 The Refactoring and Metrics Tool for TTCN-3 Test Specifications

10

Refactoring: Definition

„a change made to the internal structure of software to make it easier to understand and cheaper to modify without changing its observable behavior“

Fowler, M.: Refactoring – Improving the Design of Existing Code. Addison-Wesley (1999)

Page 11: 1 TRex Paul Baker 1, Dominic Evans 1, Jens Grabowski 2, Helmut Neukirchen 2, Benjamin Zeiss 2 The Refactoring and Metrics Tool for TTCN-3 Test Specifications

11

TTCN-3 Refactoring Catalog

• Refactorings are typically described in catalogsName, Summary, Motivation, Mechanics, Example

• 28 (of 72) refactorings from Fowler are applicable

• 20 specific refactorings for TTCN-3e.g. Alt-steps, groups, concurrency, module parameterization

• TTCN-3 refactoring catalog grouping:– Test behavior– Data descriptions– Overall test suite structure

Page 12: 1 TRex Paul Baker 1, Dominic Evans 1, Jens Grabowski 2, Helmut Neukirchen 2, Benjamin Zeiss 2 The Refactoring and Metrics Tool for TTCN-3 Test Specifications

12

TTCN-3 Refactoring Catalog

• TTCN-3 specific refactorings:

– Test behavior (5 refactorings)• Extract Altstep• …

– Data descriptions (6 refactorings)• Inline Template• …

– Overall test suite structure (9 refactorings)• Extract Module• …

Page 13: 1 TRex Paul Baker 1, Dominic Evans 1, Jens Grabowski 2, Helmut Neukirchen 2, Benjamin Zeiss 2 The Refactoring and Metrics Tool for TTCN-3 Test Specifications

13

Refactoring: Inline Template Parameter (1/2)

module ExampleModule { type record ExampleType { boolean ipv6, charstring ipAddress }

template ExampleType exampleTemplate(charstring addressParameter) := { ipv6 := false, ipAddress := addressParameter }

testcase exampleTestCase() runs on ExampleComponent { pt.send(exampleTemplate("127.0.0.1")); pt.receive(exampleTemplate("127.0.0.1")); }

}

• Original code:

Page 14: 1 TRex Paul Baker 1, Dominic Evans 1, Jens Grabowski 2, Helmut Neukirchen 2, Benjamin Zeiss 2 The Refactoring and Metrics Tool for TTCN-3 Test Specifications

14

module ExampleModule { type record ExampleType { boolean ipv6, charstring ipAddress }

template ExampleType exampleTemplate := { ipv6 := false, ipAddress := "127.0.0.1" }

testcase exampleTestCase() runs on ExampleComponent { pt.send(exampleTemplate); pt.receive(exampleTemplate) }

}

Refactoring: Inline Template Parameter (2/2)

• Refactored code:

Page 15: 1 TRex Paul Baker 1, Dominic Evans 1, Jens Grabowski 2, Helmut Neukirchen 2, Benjamin Zeiss 2 The Refactoring and Metrics Tool for TTCN-3 Test Specifications

15

Automation

• Automated calculation of metrics – Locates problematic code pieces using appropriate

boundary values– Used for refactoring suggestions

• Tool supported refactoring– Lowers the probability that the observable behavior is

changed due to a refactoring

– Takes less time than manual refactoring

– Is well known from the Java world: Eclipse JDT, Jetbrains IDEA

Page 16: 1 TRex Paul Baker 1, Dominic Evans 1, Jens Grabowski 2, Helmut Neukirchen 2, Benjamin Zeiss 2 The Refactoring and Metrics Tool for TTCN-3 Test Specifications

16

Outline

• Motivation

• Metrics

• Refactoring

• TRex Tool

• Summary / Outlook

Page 17: 1 TRex Paul Baker 1, Dominic Evans 1, Jens Grabowski 2, Helmut Neukirchen 2, Benjamin Zeiss 2 The Refactoring and Metrics Tool for TTCN-3 Test Specifications

17

TRex Features (1/3)

• TTCN-3 core notation editing– Syntax Highlighting– Content Assist– Outline View– Code Formatter– Text hover– Open Declaration– Find References

• Compiler Integration– Telelogic Tau G2/Tester

Page 18: 1 TRex Paul Baker 1, Dominic Evans 1, Jens Grabowski 2, Helmut Neukirchen 2, Benjamin Zeiss 2 The Refactoring and Metrics Tool for TTCN-3 Test Specifications

18

TRex Features (2/3)

• Refactorings (currently):– Rename– Inline Template– Inline Template Parameter– Parameterize Template

• Metrics– Basic metrics– Metrics-based refactoring suggestions

Page 19: 1 TRex Paul Baker 1, Dominic Evans 1, Jens Grabowski 2, Helmut Neukirchen 2, Benjamin Zeiss 2 The Refactoring and Metrics Tool for TTCN-3 Test Specifications

19

TRex Features (3/3)

Page 20: 1 TRex Paul Baker 1, Dominic Evans 1, Jens Grabowski 2, Helmut Neukirchen 2, Benjamin Zeiss 2 The Refactoring and Metrics Tool for TTCN-3 Test Specifications

20

Outline

• Motivation

• Metrics

• Refactoring

• TRex Tool

• Summary / Outlook

Page 21: 1 TRex Paul Baker 1, Dominic Evans 1, Jens Grabowski 2, Helmut Neukirchen 2, Benjamin Zeiss 2 The Refactoring and Metrics Tool for TTCN-3 Test Specifications

21

Summary

• Metrics and refactoring for TTCN-3:– Address maintenance, reusability and readability

problems of converted legacy test suites– Less error-prone and less time consuming due to

tool support

• TRex: – IDE for TTCN-3– Automatic assessment and restructuring of test

suites

Page 22: 1 TRex Paul Baker 1, Dominic Evans 1, Jens Grabowski 2, Helmut Neukirchen 2, Benjamin Zeiss 2 The Refactoring and Metrics Tool for TTCN-3 Test Specifications

22

TRex Availability

• TRex is open source and available now!

• Eclipse Public License

• Interested java developers are welcome to join the project

www.trex.informatik.uni-goettingen.de

Page 23: 1 TRex Paul Baker 1, Dominic Evans 1, Jens Grabowski 2, Helmut Neukirchen 2, Benjamin Zeiss 2 The Refactoring and Metrics Tool for TTCN-3 Test Specifications

23

Outlook

• Enhanced editing functionality

• More refactoring implementations

• Metrics based on control-flow and call-graphs

• Identification of useful metric boundary values

• Automatic pattern-based code smell detection

Page 24: 1 TRex Paul Baker 1, Dominic Evans 1, Jens Grabowski 2, Helmut Neukirchen 2, Benjamin Zeiss 2 The Refactoring and Metrics Tool for TTCN-3 Test Specifications

24

www.trex.informatik.uni-goettingen.de

Page 25: 1 TRex Paul Baker 1, Dominic Evans 1, Jens Grabowski 2, Helmut Neukirchen 2, Benjamin Zeiss 2 The Refactoring and Metrics Tool for TTCN-3 Test Specifications

25

• Backup

Page 26: 1 TRex Paul Baker 1, Dominic Evans 1, Jens Grabowski 2, Helmut Neukirchen 2, Benjamin Zeiss 2 The Refactoring and Metrics Tool for TTCN-3 Test Specifications

26

TRex tool chain

(3) Quality Assessment (2) Automated Refactorings

(1) Static Analysis

Eclipse PlatformUser

InterfaceResource

ManagementText

EditorLanguage

Toolkit...

TTCN-3Core

Notation

ANTLRLexing,Parsing

Refactoring Processor

RefactoredTTCN-3

CoreNotation

Transformed Subtree of theSyntax Tree

Pretty Printer

Change Weaver

Syntax Tree /Symbol Table

Metrics

Rule-Based Refactoring Suggestions

Page 27: 1 TRex Paul Baker 1, Dominic Evans 1, Jens Grabowski 2, Helmut Neukirchen 2, Benjamin Zeiss 2 The Refactoring and Metrics Tool for TTCN-3 Test Specifications

27

TRex ArchitectureTRex Feature

TRex ANTLR Plug-In

Eclipse Platform

TRex Refactoring UI

Trex Core Plug-In

TTCN-3 Parser

Syntax Tree

Code Formatter Symbol Table

TRex UI Plug-In

Content Assist Find References View TexthoverTTCN-3 Editor

TRex Refactoring Core

Inline Template Rename Inline Template Parameter Merge Templates