330 likes | 575 Views
The Use of TTCN-3 for Software Testing. Ina Schieferdecker FOKUS, Berlin schieferdecker@fokus.fhg.de. Content. Overview on TTCN-3 TTCN-3 applied to software TTCN-3 and XML Test Execution. Content. Overview on TTCN-3 TTCN-3 applied to software TTCN-3 and XML Test Execution.
E N D
The Use of TTCN-3for Software Testing Ina Schieferdecker FOKUS, Berlin schieferdecker@fokus.fhg.de
Content • Overview on TTCN-3 • TTCN-3 applied to software • TTCN-3 and XML • Test Execution
Content • Overview on TTCN-3 • TTCN-3 applied to software • TTCN-3 and XML • Test Execution
Introduction • TTCN-3 is the Testing and Test Control Notation • The new standardised test specification and test implementation language • Developed from 1999 – 2002 at the European Telecommunications Standards Institute (ETSI). • Developed based on experiences from previous TTCN editions • Removal of OSI specific concepts; Improvement of concepts; Introduction of new concepts. • Applicable for all kinds of black-box testing for reactive and distributed systems, e.g., • Telecom systems (ISDN, ATM, GSM, UMTS); Internet (IP, IP based protocols and applications); Software systems (Java, XML); Middleware platforms and component-based systems (CORBA, .Net, EJB).
msc mi_synch1_conc1 mtc ISAP1 MSAP2 Other Types & Values 2 Overview on TTCN-3 TTCN-3 Core Language ASN.1 Types & Values Tabular Format : testcase myTestcase () runson MTCType system TSIType {mydefault := activate (OtherwiseFail); verdict.set(pass); : connect(PTC_ISAP1:CP_ISAP1,mtc:CP_ISAP1); : map(PTC_ISAP1:ISAP1, system:TSI_ISAP1); : PTC_ISAP1.start(func_PTC_ISAP1()); PTC_MSAP2.start(func_PTC_MSAP2()); Synchronization(); allcomponent.done; log(”Correct Termination”); } : Graphical Format Presentation Format n Other Types & Values n
TTCN-3 Test Case Port.send(Stimulus) Port.receive(Response) Port System Under Test TTCN-3 – Based Black-Box Testing • Assignmentof aTest Verdict
SUT create start TC TC TC MTC TCs TCs TCs TC TC TC create start create start Component-Based Test System TTCN-3 Test Case
Main Elements of TTCN-3 • Module covers declarations and control • Templates (test data description) and matching mechanisms (pattern matching) • Test configurations • Formally defined interfaces to the SUT • Dynamic creation of test component • Concurrency to describe distributed test setups • Test cases • Small (complete) separate compilable programs • Share (type and data) information • Test verdicts
Content • Overview on TTCN-3 • TTCN-3 applied to software • TTCN-3 and XML • Test Execution
Message-Based Software Such as Protocols, Messaging Services, Web site and Portals, ... Example technology is XML Signature-Based Software Such as Client-Server, Peer-to-Peer, Component-based Systems, .... Example technology is IDL TTCN-3 and Software Testing • Reuse of XML/IDL/... data within TTCN-3 • Define a mapping from XML/IDL/... to TTCN-3
IDL C, C++, JAVA XML Other Types & Values 2 Presentation Format n TTCN-3 and Software Testing TTCN-3 Core Language ASN.1 Types & Values Tabular Format Graphical Format Presentation Format n Other Types & Values n
Content • Overview on TTCN-3 • TTCN-3 applied to software • TTCN-3 and XML • Test Execution
XML in Distributed Applications • Increasing number of distributed applications use XML for • Description of messages in datacom protocols • Exchange format between software components • Data description in Web-applications • etc. • XML • is a structured method for putting data into a textual presentation by marking up data • can have attributes that describe additional information • describes both attributes and content • is intuitive and self describing
Mapping XML to TTCN-3 • Idea: Map element tags and attributes to TTCN-3 fields • Different grammar definitions and mappings • Schemas • Embedded approach • Flat-Catalog approach • Named Type approach • DTDs
Example Paleontologist feeding the database Student requesting data XML Example – The Dinosaur Database
XML File XML The Request Interface URL http://www.testingtech.de/TTCN-3_Example/dinolist.xml
Generation of test data XML Generation of test data structure Generation of test behavior Adaptor acc. to the mapping rules Compilation to Executable Tests A D A P T O R Test Component Test Component Test Component Test Component Web Service Test System Principal Approach
Example Structured Type Defintions <!ELEMENT dinolist (dinosaur*)> <!ELEMENT dinosaur (name, len, mass, time, place)> <!ELEMENT name (#PCDATA)> <!ELEMENT len (#PCDATA)> <!ELEMENT mass (#PCDATA)> <!ELEMENT time (#PCDATA)> <!ELEMENT place (#PCDATA)> typeset of dinosaur dinolist; typerecord dinosaur { charstring name, charstring len, charstring mass, charstring time, charstring place } XML DTD Set of Type Definition Record Type Definition Field Definition
Example Test Data Definitions templatedinolistDinoList:= {?, ?, Brachiosaurus, ?, ?, ?, ?}; templatedinosaurBrachiosaurus:= { name := "Brachiosaurus", len := ?, mass := ?, time := ?, place := ? } Any Value
Example Test Port /** communication port type definition */ type porthttpTestPortType message { out url; in dinolist; } Port Definition
Example Test Components /** component type definitions */ type component httpTestComponent{ port httpTestPortTypehttpPort; timer localTimer := 3.0; } type component httpTestSystemComponent{ port httpTestPortTypehttpTestSystemPort; } Component Definition Local Port Local Timer
Example Test Behavior Sending a message Starting the timer httpPort.send(requestURL); localTimer.start; alt { [] httpPort.receive(DinoList) { localTimer.stop; setverdict(pass); } [] httpPort.receive { localTimer.stop; setverdict(fail); } [] localTimer.timeout { setverdict(fail); } } Alternative reactions The expected response An unexpected response A timeout
Example Simplification: Altstep altstepDinoList_Default_1() runson httpTestComponent { [] httpPort.receive { localTimer.stop; setverdict(fail); } [] localTimer.timeout { setverdict(fail); } } Test Component Type Handling of unexpected response Handling of timeouts
Example Simplification: Use of the Altstep ... activate(DinoList_Default_1()); httpPort.send(requestURL); localTimer.start; httpPort.receive(DinoList); localTimer.stop; setverdict(pass); … Default activation The expected response is given here only, All other cases are handled by the default
Example A Test Case Test Case Definition testcaseDinoList_Test_1() runson httpTestComponent system httpTestSystemComponent { map(mtc:httpPort, system:httpTestSystemPort); activate(DinoList_Default_1()); httpPort.send(requestURL); localTimer.start; httpPort.receive(DinoList); localTimer.stop; setverdict(pass); } MTC Type TSI Type Mapping the Ports
testcaseDinoList_Test_1 runs on httpTestComponent system httpTestSystemComponent mtc httpPort httpTestComponent activate(DinoList_Default_1) LocalTimer requestURL DinoList pass Graphical Format map(mtc:httpPort,system:httpTestSystemPort)
Content • Overview on TTCN-3 • TTCN-3 applied to software • TTCN-3 and XML • Test Execution
Test System Connected Ports INOUT TC2 OUT IN OUT IN Mapped Ports OUT IN Real Test System Interface Real Test System Interface SUT TC1 Test Execution Abstract Test System Interface
TTCN-3 Execution • Generic XML adaptor that adheres to the mapping Test System User Test System TM: Management TE CD: CoDec CH: ComponentHandling SA: Communication PA: Timer System Under Test (SUT)
Test System User TM: Management TE CD: CoDec CH: ComponentHandling TRI SA: Communication PA: Timer System Under Test (SUT) TTCN-3 Runtime Interface • Adaptation to the SUT
Test System User TM: Management TCI TE CD: CoDec CH: ComponentHandling SA: Communication PA: Timer System Under Test (SUT) TTCN-3 Control Interfaces • Adaptation to the test platform/test device
Summary of TTCN-3 • New version of the only standardized test notation • Modernization: Programming-like test specification with flexible data support and various representation formats • Wider scope of application • applicable to many kinds of test applications not just conformance (development, system, integration, interoperability, scalability …) • applicable in the datacom domain • Harmonization • first choice for test specifiers, implementors and users both for standardized test suites and • as a generic solution in industrial software development • Was successfully shown to be applicable to testing of IDL and XML interfaces, Java and C++ classes, … • Tools are available