SlideShare ist ein Scribd-Unternehmen logo
1 von 27
Downloaden Sie, um offline zu lesen
PyCon JP 2011 LT




        Oktest
a new style testing library for Python


                 makoto kuwata
          http://www.kuwata-lab.com/


        copyright(c) 2011 kuwata-lab.com all rights reserved.
                                                                              1
unittest
           (python)


copyright(c) 2011 kuwata-lab.com all rights reserved.
                                                        2
Too long! Hard to read & write!
                                     !                                  !




                copyright(c) 2011 kuwata-lab.com all rights reserved.
                                                                            3
Test::More
                  (perl)


copyright(c) 2011 kuwata-lab.com all rights reserved.
                                                        4
Easy to read & write! Kool!




      copyright(c) 2011 kuwata-lab.com all rights reserved.
                                                              5
Oktest
           (python)


copyright(c) 2011 kuwata-lab.com all rights reserved.
                                                        6
So Kooooooool!



                  copyright(c) 2011 kuwata-lab.com all rights reserved.
                                                                          7
Kool Python!                                         Not kool. It's Java.
     Python                                                      Java




                            copyright(c) 2011 kuwata-lab.com all rights reserved.
                                                                                                   8
ok() returns AssertionObject
                                  ok()        AssertionObject

       	    	 
                                                              	 

       	    	 
                     	                 	                   	             	 
	 	 
                                       	  	          	  	  	 
                                      Overrides '==' operator
                                       '=='




                 copyright(c) 2011 kuwata-lab.com all rights reserved.
                                                                              9
Shows unified diff when '==' is failed.
	                                 '=='                    uniifed diff             (2.6   !)




                           copyright(c) 2011 kuwata-lab.com all rights reserved.
                                                                                               10
Test Code                                 When Failed
  	          	 	 	 	 	 	 	 	 	 
        	  	  	  	 	 	 	 	 	 (no message)

  	       	 	 	 	 	 	 	 	 	 	 	 
       	  	  	 	 	 	 	 	 	 	 (no message)

  	          	 	 	 	 	 	 	 	 	 
  	     	  	  	 	 	 	 	 	 	 	  	  	  	  	 

                  Shows actual & expected values


            copyright(c) 2011 kuwata-lab.com all rights reserved.
                                                                    11
unittest
           (python)


copyright(c) 2011 kuwata-lab.com all rights reserved.
                                                        12
You must describe in [a-zA-Z0-9_]+
                                (         )                             _
         	 

	 	      	 
	 	 	 	          	  	  	                         	        	 
	 	 	 	                                                      	 

                         Duplicated. Not DRY!
                                                          DRY




                copyright(c) 2011 kuwata-lab.com all rights reserved.
                                                                            13
Oktest
           (python)


copyright(c) 2011 kuwata-lab.com all rights reserved.
                                                        14
Free text instead of method name!
                                                                        !




                copyright(c) 2011 kuwata-lab.com all rights reserved.
                                                                            15
Any symbol or CJK available!



                copyright(c) 2011 kuwata-lab.com all rights reserved.
                                                                        16
internal

                  	 	  	             	  	  	                           	    	 
                    	  	                           	 
	 	 	 	 	 	 	 	 	 	 	 	 	            	  	  	                           	    	 
                                                   	  	 
                 Set free text as method name,
               keeping with unittest compatibility
               unittest



               copyright(c) 2011 kuwata-lab.com all rights reserved.
                                                                                 17
Fixture Injection
            in Oktest


   copyright(c) 2011 kuwata-lab.com all rights reserved.
                                                           18
All test methods call the same 'setUp()'. Coarse-grained.
 Want to call different initializer for each test method.
                                 setUp()


         	 

	 	      	 
	 	 	 	                      	  	 
	 	 	 	                  	 	 	  	 

	 	      	 
	 	 	 	  	                                              	       	 

	 	      	 
	 	 	 	  	                                         	       	 
              copyright(c) 2011 kuwata-lab.com all rights reserved.
                                                                      19
Calls provide_member() only
	 	      	                                         	 
	 	 	 	  	                                 	       	 
	 	      	                                    	 
	 	 	 	  	                            	       	 
                                                        Calls provide_team() only

              copyright(c) 2011 kuwata-lab.com all rights reserved.
                                                                                    20
- 'A' depends on 'B' and 'C'
                                     - 'C' depends on 'D'
                                       A B C                      C     D

	 	      	                                    	                   	 
	 	      	                              	 	 	 	                   	 
	 	      	                                	 	 	                   	 
	 	      	                              	 	 	 	                   	 

	 	       	                                                    	 
	 	 	 	 	 	    	        	       	               	            	              	 
                    Dependencies are resolved automatically
                                           Oktest


                copyright(c) 2011 kuwata-lab.com all rights reserved.
                                                                                 21
Equivarent to setUp()
                                        provide_xxx()       setUp()

	 	       	 
	 	 	 	                  	  	 
	 	 	 	        	                                     	            	     	 
	 	 	 	 	 	 
	 	 	 	             	 
                                  Equivarent to tearDown()
                                     release_xxx()        tearDown()

	 	       	                                                	 
	 	 	 	  	 
	 	 	 	 	 	 

                copyright(c) 2011 kuwata-lab.com all rights reserved.
                                                                             22
Interested?


copyright(c) 2011 kuwata-lab.com all rights reserved.
                                                        23
Oktest Python                                       Google Search




     copyright(c) 2011 kuwata-lab.com all rights reserved.
                                                                    24
one more thing...


  copyright(c) 2011 kuwata-lab.com all rights reserved.
                                                          25
Oktest for Node.js
      	             	    	 
	 	 	 	           	 	    	 
	 	 	 	         	 	 	    	 
	 	 	 	     	 	 	 	 	    	 

                                    	                      	 
	 	                                                	                    	 
	 	 	 	                                                    	                 	 
	 	 	 	 	 	     	 
	 	 	 	 	 	     	             	          	 
	 	 	 	 
	 	 


    	                                 	       	 
	 	 

                     copyright(c) 2011 kuwata-lab.com all rights reserved.
                                                                                  26
thank you


copyright(c) 2011 kuwata-lab.com all rights reserved.
                                                        27

Weitere ähnliche Inhalte

Mehr von kwatch

文字列結合のベンチマークをいろんな処理系でやってみた
文字列結合のベンチマークをいろんな処理系でやってみた文字列結合のベンチマークをいろんな処理系でやってみた
文字列結合のベンチマークをいろんな処理系でやってみた
kwatch
 
I have something to say about the buzz word "From Java to Ruby"
I have something to say about the buzz word "From Java to Ruby"I have something to say about the buzz word "From Java to Ruby"
I have something to say about the buzz word "From Java to Ruby"
kwatch
 

Mehr von kwatch (20)

How to make the fastest Router in Python
How to make the fastest Router in PythonHow to make the fastest Router in Python
How to make the fastest Router in Python
 
Migr8.rb チュートリアル
Migr8.rb チュートリアルMigr8.rb チュートリアル
Migr8.rb チュートリアル
 
なんでもID
なんでもIDなんでもID
なんでもID
 
Nippondanji氏に怒られても仕方ない、配列型とJSON型の使い方
Nippondanji氏に怒られても仕方ない、配列型とJSON型の使い方Nippondanji氏に怒られても仕方ない、配列型とJSON型の使い方
Nippondanji氏に怒られても仕方ない、配列型とJSON型の使い方
 
【SQLインジェクション対策】徳丸先生に怒られない、動的SQLの安全な組み立て方
【SQLインジェクション対策】徳丸先生に怒られない、動的SQLの安全な組み立て方【SQLインジェクション対策】徳丸先生に怒られない、動的SQLの安全な組み立て方
【SQLインジェクション対策】徳丸先生に怒られない、動的SQLの安全な組み立て方
 
O/Rマッパーによるトラブルを未然に防ぐ
O/Rマッパーによるトラブルを未然に防ぐO/Rマッパーによるトラブルを未然に防ぐ
O/Rマッパーによるトラブルを未然に防ぐ
 
正規表現リテラルは本当に必要なのか?
正規表現リテラルは本当に必要なのか?正規表現リテラルは本当に必要なのか?
正規表現リテラルは本当に必要なのか?
 
【公開終了】Python4PHPer - PHPユーザのためのPython入門 (Python2.5)
【公開終了】Python4PHPer - PHPユーザのためのPython入門 (Python2.5)【公開終了】Python4PHPer - PHPユーザのためのPython入門 (Python2.5)
【公開終了】Python4PHPer - PHPユーザのためのPython入門 (Python2.5)
 
DBスキーマもバージョン管理したい!
DBスキーマもバージョン管理したい!DBスキーマもバージョン管理したい!
DBスキーマもバージョン管理したい!
 
PHPとJavaScriptにおけるオブジェクト指向を比較する
PHPとJavaScriptにおけるオブジェクト指向を比較するPHPとJavaScriptにおけるオブジェクト指向を比較する
PHPとJavaScriptにおけるオブジェクト指向を比較する
 
SQL上級者こそ知って欲しい、なぜO/Rマッパーが重要か?
SQL上級者こそ知って欲しい、なぜO/Rマッパーが重要か?SQL上級者こそ知って欲しい、なぜO/Rマッパーが重要か?
SQL上級者こそ知って欲しい、なぜO/Rマッパーが重要か?
 
Fantastic DSL in Python
Fantastic DSL in PythonFantastic DSL in Python
Fantastic DSL in Python
 
What is wrong on Test::More? / Test::Moreが抱える問題点とその解決策
What is wrong on Test::More? / Test::Moreが抱える問題点とその解決策What is wrong on Test::More? / Test::Moreが抱える問題点とその解決策
What is wrong on Test::More? / Test::Moreが抱える問題点とその解決策
 
PHP5.5新機能「ジェネレータ」初心者入門
PHP5.5新機能「ジェネレータ」初心者入門PHP5.5新機能「ジェネレータ」初心者入門
PHP5.5新機能「ジェネレータ」初心者入門
 
Pretty Good Branch Strategy for Git/Mercurial
Pretty Good Branch Strategy for Git/MercurialPretty Good Branch Strategy for Git/Mercurial
Pretty Good Branch Strategy for Git/Mercurial
 
文字列結合のベンチマークをいろんな処理系でやってみた
文字列結合のベンチマークをいろんな処理系でやってみた文字列結合のベンチマークをいろんな処理系でやってみた
文字列結合のベンチマークをいろんな処理系でやってみた
 
I have something to say about the buzz word "From Java to Ruby"
I have something to say about the buzz word "From Java to Ruby"I have something to say about the buzz word "From Java to Ruby"
I have something to say about the buzz word "From Java to Ruby"
 
Cより速いRubyプログラム
Cより速いRubyプログラムCより速いRubyプログラム
Cより速いRubyプログラム
 
Javaより速いLL用テンプレートエンジン
Javaより速いLL用テンプレートエンジンJavaより速いLL用テンプレートエンジン
Javaより速いLL用テンプレートエンジン
 
Underlaying Technology of Modern O/R Mapper
Underlaying Technology of Modern O/R MapperUnderlaying Technology of Modern O/R Mapper
Underlaying Technology of Modern O/R Mapper
 

Kürzlich hochgeladen

Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 

Kürzlich hochgeladen (20)

"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 

Oktest - a new style testing library for Python -

  • 1. PyCon JP 2011 LT Oktest a new style testing library for Python makoto kuwata http://www.kuwata-lab.com/ copyright(c) 2011 kuwata-lab.com all rights reserved. 1
  • 2. unittest (python) copyright(c) 2011 kuwata-lab.com all rights reserved. 2
  • 3. Too long! Hard to read & write! ! ! copyright(c) 2011 kuwata-lab.com all rights reserved. 3
  • 4. Test::More (perl) copyright(c) 2011 kuwata-lab.com all rights reserved. 4
  • 5. Easy to read & write! Kool! copyright(c) 2011 kuwata-lab.com all rights reserved. 5
  • 6. Oktest (python) copyright(c) 2011 kuwata-lab.com all rights reserved. 6
  • 7. So Kooooooool! copyright(c) 2011 kuwata-lab.com all rights reserved. 7
  • 8. Kool Python! Not kool. It's Java. Python Java copyright(c) 2011 kuwata-lab.com all rights reserved. 8
  • 9. ok() returns AssertionObject ok() AssertionObject Overrides '==' operator '==' copyright(c) 2011 kuwata-lab.com all rights reserved. 9
  • 10. Shows unified diff when '==' is failed. '==' uniifed diff (2.6 !) copyright(c) 2011 kuwata-lab.com all rights reserved. 10
  • 11. Test Code When Failed (no message) (no message) Shows actual & expected values copyright(c) 2011 kuwata-lab.com all rights reserved. 11
  • 12. unittest (python) copyright(c) 2011 kuwata-lab.com all rights reserved. 12
  • 13. You must describe in [a-zA-Z0-9_]+ ( ) _ Duplicated. Not DRY! DRY copyright(c) 2011 kuwata-lab.com all rights reserved. 13
  • 14. Oktest (python) copyright(c) 2011 kuwata-lab.com all rights reserved. 14
  • 15. Free text instead of method name! ! copyright(c) 2011 kuwata-lab.com all rights reserved. 15
  • 16. Any symbol or CJK available! copyright(c) 2011 kuwata-lab.com all rights reserved. 16
  • 17. internal Set free text as method name, keeping with unittest compatibility unittest copyright(c) 2011 kuwata-lab.com all rights reserved. 17
  • 18. Fixture Injection in Oktest copyright(c) 2011 kuwata-lab.com all rights reserved. 18
  • 19. All test methods call the same 'setUp()'. Coarse-grained. Want to call different initializer for each test method. setUp() copyright(c) 2011 kuwata-lab.com all rights reserved. 19
  • 20. Calls provide_member() only Calls provide_team() only copyright(c) 2011 kuwata-lab.com all rights reserved. 20
  • 21. - 'A' depends on 'B' and 'C' - 'C' depends on 'D' A B C C D Dependencies are resolved automatically Oktest copyright(c) 2011 kuwata-lab.com all rights reserved. 21
  • 22. Equivarent to setUp() provide_xxx() setUp() Equivarent to tearDown() release_xxx() tearDown() copyright(c) 2011 kuwata-lab.com all rights reserved. 22
  • 24. Oktest Python Google Search copyright(c) 2011 kuwata-lab.com all rights reserved. 24
  • 25. one more thing... copyright(c) 2011 kuwata-lab.com all rights reserved. 25
  • 26. Oktest for Node.js copyright(c) 2011 kuwata-lab.com all rights reserved. 26
  • 27. thank you copyright(c) 2011 kuwata-lab.com all rights reserved. 27