Upload
others
View
4
Download
0
Embed Size (px)
Citation preview
W I S S E N T E C H N I K L E I D E N S C H A F T
www.tugraz.at/institute/ist/home i ST
Quality Assurancein Software DevelopmentAssignment 2Dominik Augustin, Jorrit Stramer
Graz, 02. April 2019
2
Overview
Overview
2 Demos: IntelliTest and Code Contracts in C#
Three practical tasks (hard deadline)
Task 1: 02.04.2019, 10:30 MEZTask 2: 07.05.2019, 10:30 MEZTask 3: 04.06.2019, 10:30 MEZ
Questions
Newsgroup: tu-graz.lv.qsEmail: [email protected] (Subject: [QS19])
Dominik Augustin, Jorrit StramerGraz, 02. April 2019 i ST
3
IntelliTest
IntelliTest
Dominik Augustin, Jorrit StramerGraz, 02. April 2019 i ST
4
IntelliTest
IntelliTest
White-box test generation tool for .NET
Integrated in Visual Studio (Enterprise Editions)
Uses dynamic symbolic execution (concolicexecution)
Dominik Augustin, Jorrit StramerGraz, 02. April 2019 i ST
5
IntelliTest
Parameterized Unit Testing (PUT)
PUTs = Test methods with parameters
Perform method calls and check pre- and post-conditions
Distinguished via [PexMethod] attribute
[ PexMethod ]p u b l i c vo id AddSpec ( i n t capac i ty , ob jec t element ){
PexAssume . IsTrue ( capac i t y >= 0) ;A r r a y L i s t a = new A r r a y L i s t ( capac i t y ) ;a . Add ( element ) ;PexAssert . IsTrue ( a [ 0 ] == element ) ;
}
Dominik Augustin, Jorrit StramerGraz, 02. April 2019 i ST
6
IntelliTest
Concolic/Dynamic Symbolic Execution
Concrete and Symbolic Execution in parallel
Initially executed with simple inputs
Symbolic execution to collect constraints duringexecution
Constraint solver (e.g. Z3) for inputs to differentexecution paths (fair choice)
Goal: visit all paths
Infeasible → time limit or exploration bound
Dominik Augustin, Jorrit StramerGraz, 02. April 2019 i ST
7
IntelliTest
Example
Dominik Augustin, Jorrit StramerGraz, 02. April 2019 i ST
8
IntelliTest
Tool DemoIntelliTest
Dominik Augustin, Jorrit StramerGraz, 02. April 2019 i ST
9
IntelliTest
Keywords (IntelliTest)
[PexClass(typeof(Foo)]: Class containing PUTs forclass Foo
[PexMethod]: PUT
[PexAllowedException]: Test succeeds on specifiedexception
[PexAssumeNotNull]: Value cannot be null
[PexAssumeUnderTest]: Value cannot be null andmust be specified type
Dominik Augustin, Jorrit StramerGraz, 02. April 2019 i ST
10
IntelliTest
Keywords (IntelliTest)
PexAssume: Specify pre-condition
PexAssert: Specify post-condition
(Settings: MaxConstraintSolverTime, MaxBranches,Timeout, ...)
Dominik Augustin, Jorrit StramerGraz, 02. April 2019 i ST
11
Code Contracts
Code Contracts
Dominik Augustin, Jorrit StramerGraz, 02. April 2019 i ST
12
Code Contracts
Code Contracts
Specify what should be achieved, but not how
Theory and some examples in the lecture slides
Namespace System.Diagnostics.Contracts
Links:
Plugin: VisualStudio MarketplaceManual: Microsoft Docs
After installation: Code Contracts section in ProjectProperties
Dominik Augustin, Jorrit StramerGraz, 02. April 2019 i ST
13
Code Contracts
Tool DemoCode Contracts
Dominik Augustin, Jorrit StramerGraz, 02. April 2019 i ST
14
Code Contracts
Keywords (Code Contracts)
Contract.Requires: Specify pre-condition
Contract.Ensures: Specify post-condition
[ContractInvariantMethod]: Method with onlyinvariants
Contract.Invariant: Specify object invariant (has toalways hold)
Contract.Result: Reference to return value
Contract.OldValue: Reference to value of expressionat start of method
Dominik Augustin, Jorrit StramerGraz, 02. April 2019 i ST
15
Code Contracts
Keywords (Code Contracts)
Contract.EnsuresOnThrow: Specify post-conditionon exception
[ContractClass(typeof(Foo))]: Class Foo containsthe code contracts for this type (Bar)
[ContractClassFor(typeof(Bar)): This class (Foo)contains code contracts for type Bar
Contract.ForAll: Predicate has to be true for allelements
Contract.Exists: Predicate has to be true for at leastone element
Dominik Augustin, Jorrit StramerGraz, 02. April 2019 i ST
16
Assignment
Assignment 2Two tasks:
IntelliTest (3 + 5 points)
FunctionsMessageboard (Dispatcher and Worker)
Code Contracts (3 + 5 points)
FunctionsMessageboard (ISimulatedActorSystem)
Dominik Augustin, Jorrit StramerGraz, 02. April 2019 i ST
17
Questions
Any Questions?
Dominik Augustin, Jorrit StramerGraz, 02. April 2019 i ST