SlideShare ist ein Scribd-Unternehmen logo
1 von 25
[object Object],[object Object]
Our goal: write a function to calculate the length of the hypotenuse of a right-angled triangle from the other two sides
 
 
 
[object Object]
 
[object Object]
 
 
[object Object]
 
 
[object Object],[object Object]
We need to do each test lots of times. ,[object Object],[object Object]
 
[object Object]
[object Object]
A suite function that runs some or all of the tests.
[object Object]
A suite function that runs some or all of the tests.
Some utility functions for handling errors and displaying results.
 
 
 

Weitere ähnliche Inhalte

Was ist angesagt?

Comp 220 ilab 5 of 7
Comp 220 ilab 5 of 7Comp 220 ilab 5 of 7
Comp 220 ilab 5 of 7
ashhadiqbal
 
Data structures and algorithms lab2
Data structures and algorithms lab2Data structures and algorithms lab2
Data structures and algorithms lab2
Bianca Teşilă
 
Comp 220 ilab 6 of 7
Comp 220 ilab 6 of 7Comp 220 ilab 6 of 7
Comp 220 ilab 6 of 7
ashhadiqbal
 

Was ist angesagt? (20)

Experiment 9(exceptions)
Experiment 9(exceptions)Experiment 9(exceptions)
Experiment 9(exceptions)
 
Ecs 10 programming assignment 4 loopapalooza
Ecs 10 programming assignment 4   loopapaloozaEcs 10 programming assignment 4   loopapalooza
Ecs 10 programming assignment 4 loopapalooza
 
2CPP18 - Modifiers
2CPP18 - Modifiers2CPP18 - Modifiers
2CPP18 - Modifiers
 
Comp 220 ilab 5 of 7
Comp 220 ilab 5 of 7Comp 220 ilab 5 of 7
Comp 220 ilab 5 of 7
 
Model simulation VHDL
Model simulation VHDLModel simulation VHDL
Model simulation VHDL
 
Model simulation VHDL
Model simulation VHDLModel simulation VHDL
Model simulation VHDL
 
Nairobi JVM meetup : Introduction to akka
Nairobi JVM meetup : Introduction to akkaNairobi JVM meetup : Introduction to akka
Nairobi JVM meetup : Introduction to akka
 
Data structures and algorithms lab2
Data structures and algorithms lab2Data structures and algorithms lab2
Data structures and algorithms lab2
 
CS106 Lab 7 - For loop
CS106 Lab 7 - For loopCS106 Lab 7 - For loop
CS106 Lab 7 - For loop
 
Analytical Models of Parallel Programs
Analytical Models of Parallel ProgramsAnalytical Models of Parallel Programs
Analytical Models of Parallel Programs
 
Var arg methods
Var arg methodsVar arg methods
Var arg methods
 
Comp 220 ilab 6 of 7
Comp 220 ilab 6 of 7Comp 220 ilab 6 of 7
Comp 220 ilab 6 of 7
 
SD & D Arithmetic Operators
SD & D Arithmetic OperatorsSD & D Arithmetic Operators
SD & D Arithmetic Operators
 
CS106 Lab 3 - Modulus
CS106 Lab 3 - ModulusCS106 Lab 3 - Modulus
CS106 Lab 3 - Modulus
 
Iterable, iterator, generator by gaurav khurana
Iterable, iterator, generator by gaurav khuranaIterable, iterator, generator by gaurav khurana
Iterable, iterator, generator by gaurav khurana
 
CS106 Lab 8 - Nested loops
CS106 Lab 8 - Nested loopsCS106 Lab 8 - Nested loops
CS106 Lab 8 - Nested loops
 
lazy evaluation
lazy evaluationlazy evaluation
lazy evaluation
 
recursive problem_solving
recursive problem_solvingrecursive problem_solving
recursive problem_solving
 
Functions
FunctionsFunctions
Functions
 
Command line-arguments-in-java-tutorial
Command line-arguments-in-java-tutorialCommand line-arguments-in-java-tutorial
Command line-arguments-in-java-tutorial
 

Ähnlich wie Why you should use a testing framework

CODE TUNINGtertertertrtryryryryrtytrytrtry
CODE TUNINGtertertertrtryryryryrtytrytrtryCODE TUNINGtertertertrtryryryryrtytrytrtry
CODE TUNINGtertertertrtryryryryrtytrytrtry
kapib57390
 

Ähnlich wie Why you should use a testing framework (20)

Automation Testing theory notes.pptx
Automation Testing theory notes.pptxAutomation Testing theory notes.pptx
Automation Testing theory notes.pptx
 
maXbox Starter 36 Software Testing
maXbox Starter 36 Software TestingmaXbox Starter 36 Software Testing
maXbox Starter 36 Software Testing
 
Instant DBMS Homework Help
Instant DBMS Homework HelpInstant DBMS Homework Help
Instant DBMS Homework Help
 
Lab5
Lab5Lab5
Lab5
 
Unit 3 part2
Unit 3 part2Unit 3 part2
Unit 3 part2
 
Aaa ped-23-Artificial Neural Network: Keras and Tensorfow
Aaa ped-23-Artificial Neural Network: Keras and TensorfowAaa ped-23-Artificial Neural Network: Keras and Tensorfow
Aaa ped-23-Artificial Neural Network: Keras and Tensorfow
 
DA lecture 3.pptx
DA lecture 3.pptxDA lecture 3.pptx
DA lecture 3.pptx
 
Unit 3 part2
Unit 3 part2Unit 3 part2
Unit 3 part2
 
Unit 3 part2
Unit 3 part2Unit 3 part2
Unit 3 part2
 
Algorithm Analysis.pdf
Algorithm Analysis.pdfAlgorithm Analysis.pdf
Algorithm Analysis.pdf
 
Matlab ppt
Matlab pptMatlab ppt
Matlab ppt
 
CODE TUNINGtertertertrtryryryryrtytrytrtry
CODE TUNINGtertertertrtryryryryrtytrytrtryCODE TUNINGtertertertrtryryryryrtytrytrtry
CODE TUNINGtertertertrtryryryryrtytrytrtry
 
DATA STRUCTURE.pdf
DATA STRUCTURE.pdfDATA STRUCTURE.pdf
DATA STRUCTURE.pdf
 
DATA STRUCTURE
DATA STRUCTUREDATA STRUCTURE
DATA STRUCTURE
 
TDD Training
TDD TrainingTDD Training
TDD Training
 
To Loop or Not to Loop: Overcoming Roadblocks with FME
To Loop or Not to Loop: Overcoming Roadblocks with FMETo Loop or Not to Loop: Overcoming Roadblocks with FME
To Loop or Not to Loop: Overcoming Roadblocks with FME
 
Lazy Java
Lazy JavaLazy Java
Lazy Java
 
Mario Fusco - Lazy Java - Codemotion Milan 2018
Mario Fusco - Lazy Java - Codemotion Milan 2018Mario Fusco - Lazy Java - Codemotion Milan 2018
Mario Fusco - Lazy Java - Codemotion Milan 2018
 
Lazy java
Lazy javaLazy java
Lazy java
 
Lazy Java
Lazy JavaLazy Java
Lazy Java
 

Kürzlich hochgeladen

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
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
 

Kürzlich hochgeladen (20)

Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
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
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
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
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
"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 ...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
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...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
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
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
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
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
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
 

Why you should use a testing framework

Hinweis der Redaktion

  1. In this short presentation, I'm going to try and persuade you that you should be using a testing framework for any software that you write. The example we'll look at uses MATLAB, but the argument is applicable to any software development.
  2. Hopefully you'll be looking at this problem and thinking “this is easy, I learnt Pythagoras's theorem when I was in school”. That's good. In that case our first attempt at solving the problem will look familiar to you.
  3. As Pythagoras said, “the square of the longest side is equal to the sum of the squares of the other two sides”, or whatever the Greek equivalent is. This looks like we might have cracked it straight away. Let's test it and find out.
  4. First we test the function under normal conditions. As every school-kid knows, for a right-angled triangle with sides of length 3 and 4, the hypotenuse squared is 3 squared plus 4 squared, which is 25 and so the hypotenuse is of length 5. Likewise, the hypotenuse of the unit square is root 2. So far, so good.
  5. What if we don't pass the function any arguments? This test shows that an error is thrown when no arguments are passed to the function. You may decide that that is the most appropriate behaviour. On this occasion, let's decide that we want default values.
  6. Here's our second attempt. The additional code sets a default value of 1 when no input was passed for that length.
  7. Now that we've changed the function, we need to check that our new code passes the test. Happily, in this case it does.
  8. Another test is to see what happens when you pass empty inputs in to the function. Empty inputs should probably work in the same way as no inputs, so we have a problem here.
  9. Here's our third attempt. We need to test that this version works with empty inputs but we also need to check that we haven't introduced new bugs. Running your old tests to make sure that there are no new bugs is called regression testing.
  10. Here is our set of tests again. As you can imagine, typing in all these tests every time you change something is already really time consuming, and we're not done yet.
  11. If you've done any numeric programming before, you'll have realised that bad things often happen when you introduce very big or very small inputs. In this case, squaring the numbers causes them to over or underflow.
  12. This fourth attempt is the version that most modern scientific software uses. Explaining how it works is beyond the scope of this presentation. The important thing is that we've changed the function, so we need to run all the tests again.
  13. I'm now really bored of typing in tests, and yet we still haven't exhausted the test possibilities, e.g., What happens when non-numeric arguments are passed? What happens if non-scalar arguments are passed? What happens in the 3D (or higher dimension) case?
  14. So we've established two things. That we need to write lots of tests, and that we need to run each test lots of times. In order to save our sanity, we need a way of easily creating and running and maintaining these tests. Otherwise, laziness will take over and we'll just not bother.
  15. We could write our own function to run the tests. This is much better, but notice that there's a lot of effort involved in displaying the results, when we really just want to think about the tests themselves.
  16. A testing framework is just a formalised version of the contents of the previous slide. They generally consist of: Lots of short functions or methods representing individual tests
  17. A suite function that runs some or all of the tests.
  18. And some utility functions for handling errors and displaying results.
  19. Here's an example using the MATLAB xUnit framework. To use it, first, we create some test functions, and place them in the same directory. Here you can see the five tests we thought of earlier.
  20. We just need two more lines of code. The first line creates a suite of tests from each function, and the second line runs them all, telling us that we passed them.
  21. If we run the tests on our original version of the function instead, then the test suite shows us where our problems lie.
  22. To summarise: Firstly, thorough testing is necessary, even when you think the answer should be easy. In this case, the overflow bug was quite obscure, and you might not have picked up on it without testing.
  23. Secondly, if we use a testing framework, then thorough testing needn't be onerous. Each test was a one line function, creating and running the suite were one line each.
  24. These two ideas taken together imply that testing frameworks are a great idea.
  25. If you want to find out more, then check out these resources. Thanks for listening.