SlideShare a Scribd company logo
1 of 35
SubTests are the Best
PyOhio
July 29, 2017
Who am I?
●Dmitriy Chukhin
●Caktus Group
●Backend developer
Testing is important
●Make sure that code works
●Reduces technical debt
●Efficiency
We all know we should write tests,
but...
Good tests are:
- readable
- thorough
- DRY (Don't Repeat Yourself)
Readable Tests
Readability is important
Why not break it up into small tests?
Thorough tests
Thorough is important, and can be readable
DRY Tests
DRY testing code is important
Lessons to learn from subTests
- Readability matters
- Thorough tests can be readable and/or
short
- DRY tests are important
Do subTests solve all our testing problems?
Ways to write bad code using subTests
- comments
- variable names
- massive amounts of setup
- others
Other testing libraries?
Sure!
Contact
Dmitriy Chukhin
- github.com/dchukhin
- Twitter: @dchukhin1
Caktus Group
- caktusgroup.com
- github.com/caktus
- Twitter:
@caktusgroup

More Related Content

Similar to SubTests are the Best

TDD and Simple Design Workshop - Session 1 - March 2019
TDD and Simple Design Workshop - Session 1 - March 2019TDD and Simple Design Workshop - Session 1 - March 2019
TDD and Simple Design Workshop - Session 1 - March 2019Paulo Clavijo
 
xUnit and TDD: Why and How in Enterprise Software, August 2012
xUnit and TDD: Why and How in Enterprise Software, August 2012xUnit and TDD: Why and How in Enterprise Software, August 2012
xUnit and TDD: Why and How in Enterprise Software, August 2012Justin Gordon
 
The problem with tdd
The problem with tddThe problem with tdd
The problem with tddDror Helper
 
Introduction to Test Driven Development
Introduction to Test Driven DevelopmentIntroduction to Test Driven Development
Introduction to Test Driven DevelopmentSiva Arunachalam
 
Bdd - L'arte di non farsi i fatti propri
Bdd - L'arte di non farsi i fatti propriBdd - L'arte di non farsi i fatti propri
Bdd - L'arte di non farsi i fatti propriCommit University
 
Agile Mëtteg #5: Agile Testing
Agile Mëtteg #5: Agile TestingAgile Mëtteg #5: Agile Testing
Agile Mëtteg #5: Agile TestingAgile Partner S.A.
 
Writing Tests with the Unity Test Framework
Writing Tests with the Unity Test FrameworkWriting Tests with the Unity Test Framework
Writing Tests with the Unity Test FrameworkPeter Kofler
 
TDD for Testers Workshop
TDD for Testers WorkshopTDD for Testers Workshop
TDD for Testers WorkshopSarah Usher
 
I Don't Code, Am I No Longer Useful
I Don't Code, Am I No Longer UsefulI Don't Code, Am I No Longer Useful
I Don't Code, Am I No Longer UsefulMaaret Pyhäjärvi
 
Level Up Your Automated Tests
Level Up Your Automated TestsLevel Up Your Automated Tests
Level Up Your Automated TestsTrisha Gee
 
Atd advanced topicsworkshop
Atd advanced topicsworkshopAtd advanced topicsworkshop
Atd advanced topicsworkshoplisacrispin
 
Test Driven Development Methodology and Philosophy
Test Driven Development Methodology and Philosophy Test Driven Development Methodology and Philosophy
Test Driven Development Methodology and Philosophy Vijay Kumbhar
 
Being Test-Driven: It's not really about testing
Being Test-Driven: It's not really about testingBeing Test-Driven: It's not really about testing
Being Test-Driven: It's not really about testingRaj Indugula
 
Software Engineering Primer
Software Engineering PrimerSoftware Engineering Primer
Software Engineering PrimerGeorg Buske
 
Agile Programming Systems # TDD intro
Agile Programming Systems # TDD introAgile Programming Systems # TDD intro
Agile Programming Systems # TDD introVitaliy Kulikov
 

Similar to SubTests are the Best (20)

TDD and Simple Design Workshop - Session 1 - March 2019
TDD and Simple Design Workshop - Session 1 - March 2019TDD and Simple Design Workshop - Session 1 - March 2019
TDD and Simple Design Workshop - Session 1 - March 2019
 
xUnit and TDD: Why and How in Enterprise Software, August 2012
xUnit and TDD: Why and How in Enterprise Software, August 2012xUnit and TDD: Why and How in Enterprise Software, August 2012
xUnit and TDD: Why and How in Enterprise Software, August 2012
 
The problem with tdd
The problem with tddThe problem with tdd
The problem with tdd
 
Introduction to Test Driven Development
Introduction to Test Driven DevelopmentIntroduction to Test Driven Development
Introduction to Test Driven Development
 
Bdd - L'arte di non farsi i fatti propri
Bdd - L'arte di non farsi i fatti propriBdd - L'arte di non farsi i fatti propri
Bdd - L'arte di non farsi i fatti propri
 
Agile Technical Leadership
Agile Technical LeadershipAgile Technical Leadership
Agile Technical Leadership
 
Agile Mëtteg #5: Agile Testing
Agile Mëtteg #5: Agile TestingAgile Mëtteg #5: Agile Testing
Agile Mëtteg #5: Agile Testing
 
TDD in Agile
TDD in AgileTDD in Agile
TDD in Agile
 
Writing Tests with the Unity Test Framework
Writing Tests with the Unity Test FrameworkWriting Tests with the Unity Test Framework
Writing Tests with the Unity Test Framework
 
Code reviews
Code reviewsCode reviews
Code reviews
 
TDD for Testers Workshop
TDD for Testers WorkshopTDD for Testers Workshop
TDD for Testers Workshop
 
I Don't Code, Am I No Longer Useful
I Don't Code, Am I No Longer UsefulI Don't Code, Am I No Longer Useful
I Don't Code, Am I No Longer Useful
 
Level Up Your Automated Tests
Level Up Your Automated TestsLevel Up Your Automated Tests
Level Up Your Automated Tests
 
Atd advanced topicsworkshop
Atd advanced topicsworkshopAtd advanced topicsworkshop
Atd advanced topicsworkshop
 
Test Driven Development Methodology and Philosophy
Test Driven Development Methodology and Philosophy Test Driven Development Methodology and Philosophy
Test Driven Development Methodology and Philosophy
 
Being Test-Driven: It's not really about testing
Being Test-Driven: It's not really about testingBeing Test-Driven: It's not really about testing
Being Test-Driven: It's not really about testing
 
Software Engineering Primer
Software Engineering PrimerSoftware Engineering Primer
Software Engineering Primer
 
Test-Driven Development
Test-Driven DevelopmentTest-Driven Development
Test-Driven Development
 
Agile Programming Systems # TDD intro
Agile Programming Systems # TDD introAgile Programming Systems # TDD intro
Agile Programming Systems # TDD intro
 
TDD & Refactoring
TDD & RefactoringTDD & Refactoring
TDD & Refactoring
 

Recently uploaded

Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 

Recently uploaded (20)

Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 

SubTests are the Best

Editor's Notes

  1. Me Developing in python for a few years Previously I’ve worked as a math teacher Caktus Web development company in Durham, North Carolina Specialize in web apps, usually built in Django Other python projects
  2. Tests are there to make sure the code that we’re testing actually works Upgrading to new versions of libraries is much easier when we have tests - that way we know when upgrades break things, or even when things are going to be deprecated in the future If I can catch a bug in my code by writing unit tests, then somebody else's time isn't used up in finding these bugs during QA. It may seem like it’s faster to just not write tests, but forcing myself to write unit tests has allowed me to catch many bugs in my code. This way I can fix those bugs now instead of waiting for QA, then fixing it later. It's better to write a test and catch a bug, than to have a customer catch a bug in production
  3. but this talk isn't about why we should write tests. It's about subtests. First, a little more about testing
  4. readable: other developers understand them and can update them when updates are needed thorough: test multiple things about a function/class/endpoint DRY: We shouldn't be writing the same lines code in multiple places By the way these principles taken from the zen of python: “Readability counts.”, “Beautiful is better than ugly.”, “Explicit is better than implicit.”, and “There should be one—and preferably only one—obvious way to do it.” The rest of this talk is about making tests readable, thorough, and DRY, and specifically how subtests allow us to do these things. For people who have not seen subtests before, they are a way to break up tests into smaller sections within a single test. Why would you want to do that? Because it makes your tests more readable, allows you to be thorough, and keeps your tests DRY.
  5. Let's say we have a site with users, they each have a profile, and they can follow each other. In order to make sure we're tracking following correctly, we should write a test. We might begin with something like this. We create 3 profiles, and verify that when a profile is created, no one is following anyone else. But to add testing for when people start following others, we can add some more code
  6. So we added a section that has profile1 following profile2 and profile3 following profile1. We should also include a section on unfollowing, so let's add that As a note, I’m not explaining each line, just a high level of what we’re doing to create the test.
  7. So now we're asserting that no one is following anyone at the beginning, that adding a follower tracks followers correctly, and removing a follower tracks followers correctly. But now the test is pretty long, and if someone else wanted to read it or edit it, it would take some time to figure out everything that is being asserted. Since it really has 3 sections, let’s split it up into 3 sections
  8. Now we can see that there’s a setup section, a section with asserts, a couple thing change and second section with asserts, and something changes and a third section of asserts. We can make it better with comments for each section.
  9. The text is small, but now each section has a comment at the beginning. However, there are no comments about the database changes or any of the asserts. A better example:
  10. Now a quick look at the test shows that it has some setup at the top, and then 3 sections, each with comments about what is happening. Again, it’s not important to be able to see everything that the test is doing, but a quick look at the test shows that is has 3 sections, and the subtest comments explain what is happening in each section.
  11. Readability important: Easier to find what’s happening (especially if I come back to this code in 6 months, or if someone else needs to update the tests) More pleasant to read (people, like me, like to figure out what’s happening in the code quickly, instead of digging around for a long time). If the code is easy to read, then I can spend my time updating it, rather than trying to figure out what it’s doing. For companies, these lead to better code, better projects, and more efficiency….more money.
  12. That’s not a bad idea, and it will work to do that. For example, we could have taken each of those 3 sections and made them into their own test. However, the downside to this approach is that we have to do the same setup for each of those tests, and even more for the one where we are testing the removal of followers. Sometimes it’s not a big deal to break up one test method into many small test methods, but other times the setup we have to do is redundant, and not DRY. For instance if we have a test that requires the creation of objects from 5 different models in our test database, it would be a bad idea to repeat the same setup steps for each test. Instead, we can do the setup once, and use subtests.
  13. Let’s say we have a function, is_user_error(status_code) that returns True or False when given a status code. Should be True for any 400-level status code. One way to write tests for this function would be to write some of the most common codes into the tests. This test works and it tests a lot of the common cases. It even gives our function 100% code coverage. But this is incomplete. There are many other status codes that we’re not testing
  14. So, should we put in a line for each status code that might come up? That would be thorough...but not feasable.
  15. Instead, we can write a loop and go through each status code, but if one fails...
  16. We get a non-descript message. Some code failed, but we don’t know which one. Using a subtest parameter, we can do:
  17. We’re passing in the status code that we’re testing as a parameter into each subtest, so if something fails, we get:
  18. And we see clearly that the error is for status code 405. Ok, this was a simple example, and probably not something we would need to test in a real app, but using parameters allows us to track the value of the parameter in the subtest, and as a result we have both thorough tests and specific error messages. And we can pass in any number of parameters, so when something fails, each of those parameters gets output back for us to see. Another thing to note is that subtests run independently, so if status codes 403 and 405 both failed, we would get a failure for each, whereas without using subtests we would only get the first failure.
  19. This can actually be really helpful in diagnosing the problem in an application. If we see all of the failures at once and can see something similar for them, we may be able to diagnose the bug quickly, instead of having to work with only the information for the first failure. Here’s an example:
  20. Based on the parameters we can see that something is not right for when a person has an empty string for a first or last name, and we can quickly get on to fixing the bug. By the way, could we have passed in an assert message with those parameters? Sure, but subtests don’t have to rely on custom assert messages. We can just pass in the parameters, and they show up when something fails, and we can still use a custom assert message for anything else we may need it for. Not having to use custom assert messages in each test means that we save time, the code is DRYer, and easier to maintain, since we don’t have to read through each message when working on tests.
  21. It’s important to test all the parts of a function, not just one part of it, or that it exists. We want to actually verify that our code works, so we need to be thorough. Subtests allow us to be thorough, as well as readable, and give us more useful error messages because they are independent and can print out the parameters when they fail.
  22. Let’s say we’re testing an API endpoint, and we want to make sure that the right fields are required. There is first_name, last_name, and address. So, we write a test that POSTs to the endpoint with each of the fields missing, and we verify the response status code is that of an error. So we can ask a few questions about this test: Is it clear what’s being tested? Is the test DRY? Can we improve it? The answer is, yes, we can improve it
  23. Here’s the same test with some line breaks, and some comments. This is not bad, and with the comments on top of each section it’s relatively clear what’s happening. But really, we’re repeating the same thing 3 times, which is not DRY. Instead, we should have define this behavior in 1 place, and each subtest can test each missing field name:
  24. Now we define a helper method, get_minimum_required_data() that returns the data that is required for a successful POST. This is defined in 1 place, so it’s DRY. The test for missing data now loops through each case of missing fields, and tries to POST without that field, then asserts that the status code is 400. Why is this better? DRYer code If something about the required fields for the API endpoint changes, we only need to change it in 1 place in the tests Each case is defined neatly in one tuple. If we need to change it, we can do it quickly. Since things are defined neatly, it’s more readable. If we need to add more fields, that’s easy to do as well For another API endpoint we might have 10 fields that are required. It’s much better to just add them in one place, instead of writing the same test 10 times.
  25. Less code to read by me and other developers It’s easier to maintain, since we define things in 1 place, rather than many Subtests give us a great way to test in a way that is DRY
  26. Readablity matters, since someone will need to read through our tests in the future subtests make it easier to have readable tests, since they provide a way to break up tests into sections, and to have comments for each section It’s important to have thorough tests. We don’t want to just test a little bit of the functionality, but a reasonable amount. Subtests allow us to have thorough tests without them being really long DRY tests are important Subtests give us another tool for having DRY testing At Caktus we strive to have good code, testing, and documentation, and subtests have been helpful in allowing us to do this.
  27. No.
  28. You can still write tests with no comments or bad comments, with confusing variable names, with lots and lots of unneccesary setup, etc. However, subTests give us ways to avoid some of these things, and we can use subTests as one of a number of tools to write readable, thorough, and DRY code.
  29. Can you do all of this without subtests? Pretty much. There are multiple libraries like py.test that allow us to write readable, thorough, and DRY tests. However, there’s a way to do this in the standard python library without relying on any specific testing library. If you want to use those libraries, go for it! But subtests are always there as a tool that you can use in your testing. Whether you use them or not, they are available to help you write readable, thorough, and DRY tests. Thank you.