Towards Model-Driven Unit Testing Gregor Engels Baris Güldali Marc Lohmann 02. October rd Workshop on Model design and MoDELS 2006
© s-lab, University of Paderborn - Engels, Güldali, Lohmann: Towards Model-Driven Unit Testing Model-driven Unit TestingUnit Testing Test CasesOperationComparator Test Case InputActual Result Expected Output Pass/No Pass Test Oracle Test Case Input Models generate
© s-lab, University of Paderborn - Engels, Güldali, Lohmann: Towards Model-Driven Unit Testing Development Process
© s-lab, University of Paderborn - Engels, Güldali, Lohmann: Towards Model-Driven Unit Testing UML Class Diagrams & Visual Contracts
© s-lab, University of Paderborn - Engels, Güldali, Lohmann: Towards Model-Driven Unit Testing Model-driven Unit Testing Test Cases Operation under Test Comparator Test Case InputActual Result Expected Output Pass/No Pass Test Oracle Test Case Input Models generate
© s-lab, University of Paderborn - Engels, Güldali, Lohmann: Towards Model-Driven Unit Testing call operation under test execute original operation with call parameters Test Oracle Test driverSUT … check pre-condition check post-condition throw pre-condition exception throw post-condition exception return normally [pre-condition holds] [post-condition holds] [else] syste m state s k system state s k+1 return exception implemented by created by Programmer Designer Pass No Pass
© s-lab, University of Paderborn - Engels, Güldali, Lohmann: Towards Model-Driven Unit Testing Model-driven Unit Testing Test Cases Operation under Test Comparator Test Case InputActual Result Expected Output Pass/No Pass Test Oracle Test Case Input Models generate 1.Which test cases are adequate for testing a system wrt. a testing criterion? 2.How can a SUT be set to a state where the test cases can be executed?
© s-lab, University of Paderborn - Engels, Güldali, Lohmann: Towards Model-Driven Unit Testing Test case inputs: call parameters + system state 1.Generation of call parameters P = {cid=„abc“, prNo=„def“, num=1} 2.Generation of system state Test Case Generation Well-known test case generation techniques or random generation s input =
© s-lab, University of Paderborn - Engels, Güldali, Lohmann: Towards Model-Driven Unit Testing Setting System State …
© s-lab, University of Paderborn - Engels, Güldali, Lohmann: Towards Model-Driven Unit Testing … Setting System State 3.Generation of system setting sequence s v ⊇ s input s0s0 s1s1 s2s2 stst susu svsv … … … … … … … … cartCreate operation n … Model checking techniques for computation of the system setting sequence: cartCreate, …, operation n
© s-lab, University of Paderborn - Engels, Güldali, Lohmann: Towards Model-Driven Unit Testing Model-driven Unit Testing Test Cases Operation under Test Comparator Test Case InputActual Result Expected Output Pass/No Pass Test Oracle Test Case Input Models generate
© s-lab, University of Paderborn - Engels, Güldali, Lohmann: Towards Model-Driven Unit Testing Development Process + Testing VC Workbench JML Compiler JMLUnit JML
© s-lab, University of Paderborn - Engels, Güldali, Lohmann: Towards Model-Driven Unit Testing Conclusion To do: Discussions on MoDeVa and other platforms Applying on a bigger case study Further reasearch with the aim of a dissertation Visual contracts for behavioral specification Generation of –Test oracles –Test cases Development Process and existing tools –Editor for visual contracts –Model checking tool –Test driver
© s-lab, University of Paderborn - Engels, Güldali, Lohmann: Towards Model-Driven Unit Testing Thank you for your attention! Any questions?
© s-lab, University of Paderborn - Engels, Güldali, Lohmann: Towards Model-Driven Unit Testing Contact Software Quality Lab University of Paderborn Warburger Str Paderborn Germany Baris Güldali Telefon: Fax: