SlideShare a Scribd company logo
New Features of Test::Unit 2.0 Daniel Berger Ruby, C, Perl Win32Utils SysUtils Shards Sapphire
Test::Unit now a gem ,[object Object],[object Object]
I Do Not Know ,[object Object],[object Object],[object Object],[object Object]
How to use Test::Unit 2.x ,[object Object],[object Object],[object Object]
New Assertions ,[object Object],[object Object],[object Object]
assert_true assert_true(condition) Same as: assert_equal(true, condition) assert(condition)
assert_false assert_false(condition) Same as: assert_equal(false, condition)
assert_boolean assert_boolean(result) Same as: assert_equal(true, [true, false].include?(result))
Wow Ooh, aah.
New stuff to use within tests ,[object Object],[object Object],[object Object],[object Object],[object Object]
omit, omit_if, omit_unless Used to skip tests entirely Or in specific circumstances
Omit Examples class TC_MyTest < Test::Unit::TestCase def test_alpha omit(&quot;Buggy library. Skip&quot;) # never reach past here assert_true(1 == 1) end def test_beta omit_if(File::ALT_SEPARATOR, &quot;Skipping test on MS Windows&quot;) # Won’t run this test on MS Windows (or VMS) assert_true(1 == 1) end def test_gamma omit_unless(File::ALT_SEPARATOR, &quot;Only run on MS Windows&quot;) # Won’t run this test except on MS Windows assert_true(1 == 1) end end
Output 1) Omission: Buggy library. Skip test_alpha(TC_MyTest) omit_examples.rb:7:in `test_alpha' 2) Omission: Skipping test on MS Windows test_beta(TC_MyTest) omit_examples.rb:12:in `test_beta' 3 tests, 1 assertions, 0 failures, 0 errors, 0 pendings, 2 omissions, 0 notifications Only 1 assertion ran, the other two were skipped
pend ,[object Object],[object Object]
pend example class TC_MyTest < Test::Unit::TestCase def setup @obj = MyClass.new end def test_alpha pend(&quot;The 'alpha' function hasn't been implemented yet&quot;) assert_true(@obj.alpha) end end 1) Pending: The 'alpha' function hasn't been implemented yet test_alpha(TC_MyTest) pend_example.rb:13:in `test_alpha' 1 tests, 0 assertions, 0 failures, 0 errors, 1 pendings, 0 omissions, 0 notifications
notify ,[object Object],[object Object],[object Object]
notify example class TC_MyTest < Test::Unit::TestCase def test_alpha notify(&quot;starting the alpha test&quot;) assert_true(1 == 1) notify(&quot;finished the alpha test&quot;) end end 1) Notification: starting the alpha test test_alpha(TC_MyTest) notify_example.rb:7:in `test_alpha' 2) Notification: finished the alpha test test_alpha(TC_MyTest) notify_example.rb:9:in `test_alpha' 1 tests, 1 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 2 notifications
startup and shutdown ,[object Object],[object Object],[object Object],[object Object]
startup & shutdown example class TC_MyTest < Test::Unit::TestCase def self.startup @@file_name = File.join(Dir.pwd, 'my_test_file.txt') @@file_handle = File.open(@@file_name, 'w') end def test_file_path assert_respond_to(@@file_handle, :path) end def self.shutdown @@file_handle.close File.delete(@@file_name) end end Don’t forget the ‘self’
multiple setup & teardown ,[object Object],[object Object],[object Object],[object Object]
multiple setups class TC_MyTest < Test::Unit::TestCase def setup  # first @standard = MyClass.new end setup # second def setup_alpha @alpha = MyClass.new end setup # third def setup_beta @beta = MyClass.new end def test_stuff assert_true(1 == 1) end end
multiple teardowns class TC_MyTest < Test::Unit::TestCase def test_stuff assert_true(1 == 1) end def teardown  # last @standard = nil end teardown # second def teardown_alpha @alpha = nil end teardown # first def teardown_beta @beta = nil end end
Setup Attributes ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Attribute ‘before’ class TC_MyTest < Test::Unit::TestCase def setup #  Third puts &quot;In setup&quot; end setup #  Fourth def setup_alpha puts &quot;In setup_alpha&quot; end setup :before => :prepend #  First def setup_beta puts &quot;In setup_beta&quot; end setup :before => :append #  Second def setup_gamma puts &quot;In setup_gamma&quot; end end
Quick Rules Summary ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Better Diff Output 1) Failure: test_string_diff(TC_MyTest) [diff_example.rb:7]: <&quot;weird&quot;> expected but was <&quot;wierd&quot;>. 1) Failure: test_string_diff(TC_MyTest) [diff_example.rb:7]: <&quot;weird&quot;> expected but was <&quot;wierd&quot;>. diff: - weird ?  - + wierd ?  + Old: New:
Priority Mode ,[object Object],[object Object],[object Object],[object Object],[object Object]
Sample Priority Output 1) Failure: test_one(TC_MyTest) [priority.rb:47]: <true> expected but was <false> 2) Failure: test_two(TC_MyTest) [priority.rb:51]: <true> expected but was <false> 7 tests, 7 assertions, 2 failures , 0 errors, 0 pendings, 0 omissions, 0 notifications 1) Failure: test_one(TC_MyTest) [priority.rb:47]: <true> expected but was <false> 2) Failure: test_two(TC_MyTest) [priority.rb:51]: <true> expected but was <false> 6 tests, 6 assertions, 2 failures , 0 errors, 0 pendings, 0 omissions, 0 notifications
Forcing a test priority :must def test_blah assert_true(1 == 1) end This test will always run, regardless of the “–priority-mode” switch.
Priority Modes ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Colorized Output ,[object Object],[object Object],[object Object]
Any questions?

More Related Content

What's hot

What is objectives of software testing
What is objectives of software testingWhat is objectives of software testing
What is objectives of software testing
Software Testing Books
 
Attack and Mitigation for Insecure Deserialization
Attack and Mitigation for Insecure DeserializationAttack and Mitigation for Insecure Deserialization
Attack and Mitigation for Insecure Deserialization
Sukhpreet Singh
 
Pwning mobile apps without root or jailbreak
Pwning mobile apps without root or jailbreakPwning mobile apps without root or jailbreak
Pwning mobile apps without root or jailbreak
Abraham Aranguren
 
Testing with Spring: An Introduction
Testing with Spring: An IntroductionTesting with Spring: An Introduction
Testing with Spring: An Introduction
Sam Brannen
 
Symmetric encryption and message confidentiality
Symmetric encryption and message confidentialitySymmetric encryption and message confidentiality
Symmetric encryption and message confidentiality
CAS
 
The Joy of Proactive Security
The Joy of Proactive SecurityThe Joy of Proactive Security
The Joy of Proactive Security
Andy Hoernecke
 
ip security
ip securityip security
ip security
Chirag Patel
 
Managing code quality with SonarQube
Managing code quality with SonarQubeManaging code quality with SonarQube
Managing code quality with SonarQube
Radu Vunvulea
 
Software Testing Process
Software Testing ProcessSoftware Testing Process
Software Testing Process
guest1f2740
 
Unit Testing
Unit TestingUnit Testing
Unit Testing
Sergey Podolsky
 
18CS2005 Cryptography and Network Security
18CS2005 Cryptography and Network Security18CS2005 Cryptography and Network Security
18CS2005 Cryptography and Network Security
Kathirvel Ayyaswamy
 
Cryptography and Network security # Lecture 8
Cryptography and Network security # Lecture 8Cryptography and Network security # Lecture 8
Cryptography and Network security # Lecture 8
Kabul Education University
 
Authenticated Encryption Gcm Ccm
Authenticated Encryption Gcm CcmAuthenticated Encryption Gcm Ccm
Authenticated Encryption Gcm Ccm
Vittorio Giovara
 
IP security
IP securityIP security
IP security
shraddha mane
 
2 years with python and serverless
2 years with python and serverless2 years with python and serverless
2 years with python and serverless
Hector Canto
 
Block cipher modes of operation
Block cipher modes of operation Block cipher modes of operation
Block cipher modes of operation
harshit chavda
 
Practical Malware Analysis: Ch 10: Kernel Debugging with WinDbg
Practical Malware Analysis: Ch 10: Kernel Debugging with WinDbgPractical Malware Analysis: Ch 10: Kernel Debugging with WinDbg
Practical Malware Analysis: Ch 10: Kernel Debugging with WinDbg
Sam Bowne
 

What's hot (20)

Des
DesDes
Des
 
What is objectives of software testing
What is objectives of software testingWhat is objectives of software testing
What is objectives of software testing
 
Attack and Mitigation for Insecure Deserialization
Attack and Mitigation for Insecure DeserializationAttack and Mitigation for Insecure Deserialization
Attack and Mitigation for Insecure Deserialization
 
Pwning mobile apps without root or jailbreak
Pwning mobile apps without root or jailbreakPwning mobile apps without root or jailbreak
Pwning mobile apps without root or jailbreak
 
Testing with Spring: An Introduction
Testing with Spring: An IntroductionTesting with Spring: An Introduction
Testing with Spring: An Introduction
 
Symmetric encryption and message confidentiality
Symmetric encryption and message confidentialitySymmetric encryption and message confidentiality
Symmetric encryption and message confidentiality
 
The Joy of Proactive Security
The Joy of Proactive SecurityThe Joy of Proactive Security
The Joy of Proactive Security
 
ip security
ip securityip security
ip security
 
Managing code quality with SonarQube
Managing code quality with SonarQubeManaging code quality with SonarQube
Managing code quality with SonarQube
 
Software Testing Process
Software Testing ProcessSoftware Testing Process
Software Testing Process
 
Unit Testing
Unit TestingUnit Testing
Unit Testing
 
Password based cryptography
Password based cryptographyPassword based cryptography
Password based cryptography
 
18CS2005 Cryptography and Network Security
18CS2005 Cryptography and Network Security18CS2005 Cryptography and Network Security
18CS2005 Cryptography and Network Security
 
Cryptography and Network security # Lecture 8
Cryptography and Network security # Lecture 8Cryptography and Network security # Lecture 8
Cryptography and Network security # Lecture 8
 
Authenticated Encryption Gcm Ccm
Authenticated Encryption Gcm CcmAuthenticated Encryption Gcm Ccm
Authenticated Encryption Gcm Ccm
 
IP security
IP securityIP security
IP security
 
Automation Testing by Selenium Web Driver
Automation Testing by Selenium Web DriverAutomation Testing by Selenium Web Driver
Automation Testing by Selenium Web Driver
 
2 years with python and serverless
2 years with python and serverless2 years with python and serverless
2 years with python and serverless
 
Block cipher modes of operation
Block cipher modes of operation Block cipher modes of operation
Block cipher modes of operation
 
Practical Malware Analysis: Ch 10: Kernel Debugging with WinDbg
Practical Malware Analysis: Ch 10: Kernel Debugging with WinDbgPractical Malware Analysis: Ch 10: Kernel Debugging with WinDbg
Practical Malware Analysis: Ch 10: Kernel Debugging with WinDbg
 

Viewers also liked

Basic RSpec 2
Basic RSpec 2Basic RSpec 2
Basic RSpec 2
Triet Le Minh
 
Automated testing with RSpec
Automated testing with RSpecAutomated testing with RSpec
Automated testing with RSpec
Nascenia IT
 
Rspec 101
Rspec 101Rspec 101
Rspec 101
Jason Noble
 
Testing Ruby with Rspec (a beginner's guide)
Testing Ruby with Rspec (a beginner's guide)Testing Ruby with Rspec (a beginner's guide)
Testing Ruby with Rspec (a beginner's guide)
Vysakh Sreenivasan
 
RSpec 讓你愛上寫測試
RSpec 讓你愛上寫測試RSpec 讓你愛上寫測試
RSpec 讓你愛上寫測試
Wen-Tien Chang
 
SIA311 Better Together: Microsoft Exchange Server 2010 and Microsoft Forefron...
SIA311 Better Together: Microsoft Exchange Server 2010 and Microsoft Forefron...SIA311 Better Together: Microsoft Exchange Server 2010 and Microsoft Forefron...
SIA311 Better Together: Microsoft Exchange Server 2010 and Microsoft Forefron...
Louis Göhl
 
RSpec 2 Best practices
RSpec 2 Best practicesRSpec 2 Best practices
RSpec 2 Best practices
Andrea Reginato
 

Viewers also liked (8)

Basic RSpec 2
Basic RSpec 2Basic RSpec 2
Basic RSpec 2
 
Automated testing with RSpec
Automated testing with RSpecAutomated testing with RSpec
Automated testing with RSpec
 
MacRuby
MacRubyMacRuby
MacRuby
 
Rspec 101
Rspec 101Rspec 101
Rspec 101
 
Testing Ruby with Rspec (a beginner's guide)
Testing Ruby with Rspec (a beginner's guide)Testing Ruby with Rspec (a beginner's guide)
Testing Ruby with Rspec (a beginner's guide)
 
RSpec 讓你愛上寫測試
RSpec 讓你愛上寫測試RSpec 讓你愛上寫測試
RSpec 讓你愛上寫測試
 
SIA311 Better Together: Microsoft Exchange Server 2010 and Microsoft Forefron...
SIA311 Better Together: Microsoft Exchange Server 2010 and Microsoft Forefron...SIA311 Better Together: Microsoft Exchange Server 2010 and Microsoft Forefron...
SIA311 Better Together: Microsoft Exchange Server 2010 and Microsoft Forefron...
 
RSpec 2 Best practices
RSpec 2 Best practicesRSpec 2 Best practices
RSpec 2 Best practices
 

Similar to New Features Of Test Unit 2.x

YAPC::NA 2007 - Customizing And Extending Perl Critic
YAPC::NA 2007 - Customizing And Extending Perl CriticYAPC::NA 2007 - Customizing And Extending Perl Critic
YAPC::NA 2007 - Customizing And Extending Perl Critic
joshua.mcadams
 
Automated Unit Testing
Automated Unit TestingAutomated Unit Testing
Automated Unit Testing
Mike Lively
 
Intro to Testing in Zope, Plone
Intro to Testing in Zope, PloneIntro to Testing in Zope, Plone
Intro to Testing in Zope, Plone
Quintagroup
 
Test driven development_for_php
Test driven development_for_phpTest driven development_for_php
Test driven development_for_php
Lean Teams Consultancy
 
Running and Developing Tests with the Apache::Test Framework
Running and Developing Tests with the Apache::Test FrameworkRunning and Developing Tests with the Apache::Test Framework
Running and Developing Tests with the Apache::Test Frameworkwebhostingguy
 
Test Driven
Test DrivenTest Driven
Test Driven
Alex Chaffee
 
Unit testing
Unit testingUnit testing
Unit testing
Pooya Sagharchiha
 
MT_01_unittest_python.pdf
MT_01_unittest_python.pdfMT_01_unittest_python.pdf
MT_01_unittest_python.pdf
Hans Jones
 
Effective Unit Test Style Guide
Effective Unit Test Style GuideEffective Unit Test Style Guide
Effective Unit Test Style Guide
Jacky Lai
 
Software Testing
Software TestingSoftware Testing
Software Testing
Lambert Lum
 
How To Test Everything
How To Test EverythingHow To Test Everything
How To Test Everything
noelrap
 
Testing With Test::Class
Testing With Test::ClassTesting With Test::Class
Testing With Test::Class
Curtis Poe
 
Token Testing Slides
Token  Testing SlidesToken  Testing Slides
Token Testing Slides
ericholscher
 
Mockito with a hint of PowerMock
Mockito with a hint of PowerMockMockito with a hint of PowerMock
Mockito with a hint of PowerMock
Ying Zhang
 
Php tests tips
Php tests tipsPhp tests tips
Php tests tips
Damian Sromek
 
YAPC::NA 2007 - An Introduction To Perl Critic
YAPC::NA 2007 - An Introduction To Perl CriticYAPC::NA 2007 - An Introduction To Perl Critic
YAPC::NA 2007 - An Introduction To Perl Critic
joshua.mcadams
 
White paper for unit testing using boost
White paper for unit testing using boostWhite paper for unit testing using boost
White paper for unit testing using boostnkkatiyar
 
Unit Testing using PHPUnit
Unit Testing using  PHPUnitUnit Testing using  PHPUnit
Unit Testing using PHPUnitvaruntaliyan
 
Testing And Mxunit In ColdFusion
Testing And Mxunit In ColdFusionTesting And Mxunit In ColdFusion
Testing And Mxunit In ColdFusion
Denard Springle IV
 
Deixe o teste infectar você
Deixe o teste infectar vocêDeixe o teste infectar você
Deixe o teste infectar você
Hercules Lemke Merscher
 

Similar to New Features Of Test Unit 2.x (20)

YAPC::NA 2007 - Customizing And Extending Perl Critic
YAPC::NA 2007 - Customizing And Extending Perl CriticYAPC::NA 2007 - Customizing And Extending Perl Critic
YAPC::NA 2007 - Customizing And Extending Perl Critic
 
Automated Unit Testing
Automated Unit TestingAutomated Unit Testing
Automated Unit Testing
 
Intro to Testing in Zope, Plone
Intro to Testing in Zope, PloneIntro to Testing in Zope, Plone
Intro to Testing in Zope, Plone
 
Test driven development_for_php
Test driven development_for_phpTest driven development_for_php
Test driven development_for_php
 
Running and Developing Tests with the Apache::Test Framework
Running and Developing Tests with the Apache::Test FrameworkRunning and Developing Tests with the Apache::Test Framework
Running and Developing Tests with the Apache::Test Framework
 
Test Driven
Test DrivenTest Driven
Test Driven
 
Unit testing
Unit testingUnit testing
Unit testing
 
MT_01_unittest_python.pdf
MT_01_unittest_python.pdfMT_01_unittest_python.pdf
MT_01_unittest_python.pdf
 
Effective Unit Test Style Guide
Effective Unit Test Style GuideEffective Unit Test Style Guide
Effective Unit Test Style Guide
 
Software Testing
Software TestingSoftware Testing
Software Testing
 
How To Test Everything
How To Test EverythingHow To Test Everything
How To Test Everything
 
Testing With Test::Class
Testing With Test::ClassTesting With Test::Class
Testing With Test::Class
 
Token Testing Slides
Token  Testing SlidesToken  Testing Slides
Token Testing Slides
 
Mockito with a hint of PowerMock
Mockito with a hint of PowerMockMockito with a hint of PowerMock
Mockito with a hint of PowerMock
 
Php tests tips
Php tests tipsPhp tests tips
Php tests tips
 
YAPC::NA 2007 - An Introduction To Perl Critic
YAPC::NA 2007 - An Introduction To Perl CriticYAPC::NA 2007 - An Introduction To Perl Critic
YAPC::NA 2007 - An Introduction To Perl Critic
 
White paper for unit testing using boost
White paper for unit testing using boostWhite paper for unit testing using boost
White paper for unit testing using boost
 
Unit Testing using PHPUnit
Unit Testing using  PHPUnitUnit Testing using  PHPUnit
Unit Testing using PHPUnit
 
Testing And Mxunit In ColdFusion
Testing And Mxunit In ColdFusionTesting And Mxunit In ColdFusion
Testing And Mxunit In ColdFusion
 
Deixe o teste infectar você
Deixe o teste infectar vocêDeixe o teste infectar você
Deixe o teste infectar você
 

Recently uploaded

Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
Enhancing Performance with Globus and the Science DMZ
Enhancing Performance with Globus and the Science DMZEnhancing Performance with Globus and the Science DMZ
Enhancing Performance with Globus and the Science DMZ
Globus
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
sonjaschweigert1
 
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
UiPathCommunity
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
Pierluigi Pugliese
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
Adtran
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
Ralf Eggert
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
James Anderson
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
SOFTTECHHUB
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
Peter Spielvogel
 

Recently uploaded (20)

Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
Enhancing Performance with Globus and the Science DMZ
Enhancing Performance with Globus and the Science DMZEnhancing Performance with Globus and the Science DMZ
Enhancing Performance with Globus and the Science DMZ
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
 
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
 

New Features Of Test Unit 2.x

  • 1. New Features of Test::Unit 2.0 Daniel Berger Ruby, C, Perl Win32Utils SysUtils Shards Sapphire
  • 2.
  • 3.
  • 4.
  • 5.
  • 6. assert_true assert_true(condition) Same as: assert_equal(true, condition) assert(condition)
  • 7. assert_false assert_false(condition) Same as: assert_equal(false, condition)
  • 8. assert_boolean assert_boolean(result) Same as: assert_equal(true, [true, false].include?(result))
  • 10.
  • 11. omit, omit_if, omit_unless Used to skip tests entirely Or in specific circumstances
  • 12. Omit Examples class TC_MyTest < Test::Unit::TestCase def test_alpha omit(&quot;Buggy library. Skip&quot;) # never reach past here assert_true(1 == 1) end def test_beta omit_if(File::ALT_SEPARATOR, &quot;Skipping test on MS Windows&quot;) # Won’t run this test on MS Windows (or VMS) assert_true(1 == 1) end def test_gamma omit_unless(File::ALT_SEPARATOR, &quot;Only run on MS Windows&quot;) # Won’t run this test except on MS Windows assert_true(1 == 1) end end
  • 13. Output 1) Omission: Buggy library. Skip test_alpha(TC_MyTest) omit_examples.rb:7:in `test_alpha' 2) Omission: Skipping test on MS Windows test_beta(TC_MyTest) omit_examples.rb:12:in `test_beta' 3 tests, 1 assertions, 0 failures, 0 errors, 0 pendings, 2 omissions, 0 notifications Only 1 assertion ran, the other two were skipped
  • 14.
  • 15. pend example class TC_MyTest < Test::Unit::TestCase def setup @obj = MyClass.new end def test_alpha pend(&quot;The 'alpha' function hasn't been implemented yet&quot;) assert_true(@obj.alpha) end end 1) Pending: The 'alpha' function hasn't been implemented yet test_alpha(TC_MyTest) pend_example.rb:13:in `test_alpha' 1 tests, 0 assertions, 0 failures, 0 errors, 1 pendings, 0 omissions, 0 notifications
  • 16.
  • 17. notify example class TC_MyTest < Test::Unit::TestCase def test_alpha notify(&quot;starting the alpha test&quot;) assert_true(1 == 1) notify(&quot;finished the alpha test&quot;) end end 1) Notification: starting the alpha test test_alpha(TC_MyTest) notify_example.rb:7:in `test_alpha' 2) Notification: finished the alpha test test_alpha(TC_MyTest) notify_example.rb:9:in `test_alpha' 1 tests, 1 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 2 notifications
  • 18.
  • 19. startup & shutdown example class TC_MyTest < Test::Unit::TestCase def self.startup @@file_name = File.join(Dir.pwd, 'my_test_file.txt') @@file_handle = File.open(@@file_name, 'w') end def test_file_path assert_respond_to(@@file_handle, :path) end def self.shutdown @@file_handle.close File.delete(@@file_name) end end Don’t forget the ‘self’
  • 20.
  • 21. multiple setups class TC_MyTest < Test::Unit::TestCase def setup # first @standard = MyClass.new end setup # second def setup_alpha @alpha = MyClass.new end setup # third def setup_beta @beta = MyClass.new end def test_stuff assert_true(1 == 1) end end
  • 22. multiple teardowns class TC_MyTest < Test::Unit::TestCase def test_stuff assert_true(1 == 1) end def teardown # last @standard = nil end teardown # second def teardown_alpha @alpha = nil end teardown # first def teardown_beta @beta = nil end end
  • 23.
  • 24. Attribute ‘before’ class TC_MyTest < Test::Unit::TestCase def setup # Third puts &quot;In setup&quot; end setup # Fourth def setup_alpha puts &quot;In setup_alpha&quot; end setup :before => :prepend # First def setup_beta puts &quot;In setup_beta&quot; end setup :before => :append # Second def setup_gamma puts &quot;In setup_gamma&quot; end end
  • 25.
  • 26. Better Diff Output 1) Failure: test_string_diff(TC_MyTest) [diff_example.rb:7]: <&quot;weird&quot;> expected but was <&quot;wierd&quot;>. 1) Failure: test_string_diff(TC_MyTest) [diff_example.rb:7]: <&quot;weird&quot;> expected but was <&quot;wierd&quot;>. diff: - weird ? - + wierd ? + Old: New:
  • 27.
  • 28. Sample Priority Output 1) Failure: test_one(TC_MyTest) [priority.rb:47]: <true> expected but was <false> 2) Failure: test_two(TC_MyTest) [priority.rb:51]: <true> expected but was <false> 7 tests, 7 assertions, 2 failures , 0 errors, 0 pendings, 0 omissions, 0 notifications 1) Failure: test_one(TC_MyTest) [priority.rb:47]: <true> expected but was <false> 2) Failure: test_two(TC_MyTest) [priority.rb:51]: <true> expected but was <false> 6 tests, 6 assertions, 2 failures , 0 errors, 0 pendings, 0 omissions, 0 notifications
  • 29. Forcing a test priority :must def test_blah assert_true(1 == 1) end This test will always run, regardless of the “–priority-mode” switch.
  • 30.
  • 31.