monadws a monad based testing tool for web services
play

monadWS : A Monad-Based Testing Tool for Web Services College of - PowerPoint PPT Presentation

monadWS : A Monad-Based Testing Tool for Web Services College of Computer, Nanjing University of Posts and Telecommunications, Nanjing 210003, China j g Yingzhou Zhang, Wei Fu, Changhai Nie Email: zhangyz@njupt.edu.cn A Agenda d About


  1. monadWS : A Monad-Based Testing Tool for Web Services College of Computer, Nanjing University of Posts and Telecommunications, Nanjing 210003, China j g Yingzhou Zhang, Wei Fu, Changhai Nie Email: zhangyz@njupt.edu.cn

  2. A Agenda d • About monadWS Ab t dWS • Monads Techniques q • The monads in monadWS – HSP monad HSP d – Gen monad – TestM monad • Tool Snapshots • Tool Snapshots • Conclusion 2

  3. About monadWS About monadWS • An automatic WS testing tool based on monads techniques An automatic WS testing tool based on monads techniques • monadWS adopts • HSP monad [1] for describing WS test cases • Gen monad [2] for generating test data automatically, and and • TestM monad for building the whole WS testing. ____________________ [1] HSP (Haskell Server Pages): http://code.google.com/p/hsp/ [2] Claessen K, Hughes J. QuickCheck: a lightweight tool for random testing of [2] Cl K H h J Q i kCh k li ht i ht t l f d t ti f Haskell programs. In Proceedings of the Fifth ACM SIGPLAN international Conference on Functional Programming , New York, 2005: 268~279.

  4. Its framework It f k WSDL Specification <portType/> <types/> <binding/> <service/> XML Schema O perations SoapActions Services Data URL Generation address Strategy Gen Monads request HTTP <<Client>> SO AP Caller <<Client>> SO AP soap wrap test cases Generator (XML files) response expeted results response soap Q uickCheck HSP Monads Properties TestM Monads Test Reports

  5. A Agenda d • About monadWS Ab t dWS • Monads Techniques q • The monads in monadWS – HSP monad HSP d – Gen monad – TestM monad • Tool Snapshots • Tool Snapshots • Conclusion 5

  6. Monads Intro Monads Intro. • A general functional notation A general functional notation f : a -> b • Its monadic version of this notion f: a -> M b • Operations on monad M return :: a > M a return :: a -> M a bind :: M a -> (a -> M b) -> M b Therefore, a monad can be thought as a strategy for combining computations gy g p into more complex computations. 2011-6-15

  7. A Agenda d • About monadWS Ab t dWS • Monads Techniques q • The monads in monadWS – HSP monad HSP d – Gen monad – TestM monad • Tool Snapshots • Tool Snapshots • Conclusion 7

  8. HSP Monad: represent TC HSP Monad: represent TC  represents a WS test case as a SOAP message  can encapsulate any side effects, and lets all XML expressions be computed safely expressions be computed safely makeTC serv :: InputType -> HSP XML makeTC_serv :: InputType > HSP XML The input type of a service The input type of a service operation (say serv ), such as String, Double … 8

  9. HSP Monad: represent TC HSP Monad: represent TC makeTC serv :: InputType -> HSP XML makeTC_serv :: InputType > HSP XML For example: makeTC_getOffesetUTCTime :: Double -> HSP XML makeTC_getOffesetUTCTime d = <soap:Envelope xmlns:soap=soapURI xmlns:xsd=xsdURI> p p p p <soap:Body> <getOffesetUTCTime xmlns=operURL> <hoursOffset> <% show d %> </hoursOffset> </getOffesetUTCTime> </soap:Body> </soap:Envelope> where soapURI ="http://schemas.xmlsoap.org/soap/envelope/" xsdURI = "http://www.w3.org/2001/XMLSchema" operURL = "http://www.Nanonull.com/TimeService/" // / / 9

  10. HSP Monad: represent TC HSP Monad: represent TC makeTC getOffesetUTCTime :: Double -> HSP XML _g makeTC_getOffesetUTCTime d = <soap:Envelope xmlns:soap=soapURI xmlns:xsd=xsdURI> <soap:Body> <getOffesetUTCTime xmlns=operURL> g p <hoursOffset> <% show d %> </hoursOffset> </getOffesetUTCTime> </soap:Body> </soap:Envelope> </soap:Envelope> where soapURI ="http://schemas.xmlsoap.org/soap/envelope/" xsdURI = "http://www.w3.org/2001/XMLSchema" operURL = "http://www.Nanonull.com/TimeService/" operURL http://www.Nanonull.com/TimeService/ HSP provides interfaces for other computations through the escapes (with “<%” and “%>”) 10

  11. Gen Monad: generate data Gen Monad: generate data  automatically generates data for simple types (such as Double, Int, String and so on) class Arbitrary a where arbitrary :: Gen a y instance Arbitrary Double … instance Arbitrary Double … instance Arbitrary String instance Arbitrary String … 11

  12. Gen Monad: generate data Gen Monad: generate data class Arbitrary a where arbitrary :: Gen a arbitrary :: Gen a makeTC_getOffesetUTCTime :: Double -> HSP XML  general testing method : Step 1 Step 1. generate a test value generate a test value Step 2. generate the final test case with the value test CGe testTCGen :: IO String :: O St g testTCGen = do d <- generate (arbitrary :: Gen Double) return $ hsp2str (makeTC getOffesetUTCTime d) p ( _g ) 12

  13. Gen Monad: generate data Gen Monad: generate data makeTC getOffesetUTCTime :: Double -> HSP XML _g  general testing method : testTCGen :: IO String testTCGen :: IO String testTCGen = do d <- generate (arbitrary :: Gen Double) return $ hsp2str (makeTC_getOffesetUTCTime d) return $ hsp2str (makeTC getOffesetUTCTime d)  monadic method by liftM : on-the-fly generate y y g testTCGen2 :: IO String testTCGen2 = testTCGen2 liftM (hsp2str. makeTC_getOffesetUTCTime) $ generate (arbitrary :: Gen Double) 13

  14. Gen Monad: generate data Gen Monad: generate data  We can easily change the generation strategy through the instances of Arbitrary class. class Arbitrary a where arbitrary :: Gen a y instance Arbitrary Double where arbitrary = myDoubleGen arbitrary = myDoubleGen myDoubleGen :: Gen Double myStringGen = suchThat arbitrary guard myStringGen suchThat arbitrary guard where guard a = (a > 0) && (a < 1000) || elem a [-1, 0, 9999] || [ , , ] 14

  15. TestM Monad: t TestM Monad: testing as a monad ti d   processes WS testing as the following TestM monad: type TestM a yp Coalgebraic monad g for WS computing = CoAlgMonadT Environment monad for (EnvT TestEnv testing environment t ti i t (StateT TestState (eg. Schema type information, HSP test cases files ) )) a )) a State monad for testing states ( eg. executing time, testing results) 15

  16. CPU Time Results of Autogeneration g Test Cases for TimeService Execution Time of the Execution Time of the SOAP Messages of getOffesetUTCTime in TimeService

  17. Comparison of WSTester with Other Test Tools for Web Services Comparison of WSTester with Other Test Tools for Web Services

  18. A Agenda d • About monadWS Ab t dWS • Monads Techniques q • The monads in monadWS – HSP monad HSP d – Gen monad – TestM monad • Tool Snapshots • Tool Snapshots • Conclusion 18

  19. Snapshots of our tool monadWS dWS l t f h t S

  20. Snapshots of our tool monadWS

  21. Snapshots of our tool monadWS

  22. A Agenda d • About monadWS Ab t dWS • Monads Techniques q • The monads in monadWS – HSP monad HSP d – Gen monad – TestM monad • Tool Snapshots • Tool Snapshots • Conclusion 22

  23. C Conclusion l i • briefly introduce our monad-based testing b i fl i t d d b d t ti tool, monadWS • To automatically test web services. • monadWS can use monads related to help dWS d l t d t h l – WS test case representation, – test data autogeneration, and – test auto-execution. test auto execution. 23

  24. Conclusion C l i • monadWS can use monads related to help dWS d l t d t h l – WS test case representation, – test data autogeneration, and – test auto-execution – test auto-execution. • Future work – More comparisons with existing tools – Use more data-generation strategy g gy – Apply to WS composition (with BPEL) 24

Recommend


More recommend