100% CODE COVERAGE - Think You're Done? Think AGAIN.

100% CODE COVERAGE - Think You're Done? Think AGAIN.

ArjanCodes

3 года назад

38,849 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

Erik S
Erik S - 27.11.2022 01:50

The software development elders are 100% true...

Ответить
Danilo Guedes Dev
Danilo Guedes Dev - 05.08.2022 07:31

Nice content

Ответить
Swagfagwithswag
Swagfagwithswag - 05.05.2022 01:53

is it a good idea to have your tests rely on internal details like the tax rate? with the code thats written if the tax rates change then the tests will fail.

Ответить
TheFlamio
TheFlamio - 01.04.2022 21:36

Unittesting is only step 1 then there is component test and system test.

Ответить
Jordan G
Jordan G - 08.03.2022 23:34

Superbe vidéo thanks!

Ответить
Felipe Alvarez
Felipe Alvarez - 22.01.2022 12:08

You should introduce HYPOTHESIS for unit tests

Ответить
astronemir
astronemir - 25.10.2021 23:30

Why do you prefer pytest? I’m also only familiar with it but this seems so much simpler. I wonder why more projects don’t use base unittests..

Ответить
Fennec Besixdouze
Fennec Besixdouze - 09.10.2021 19:29

It's seems odd that you chose to use unittest for these example, it seems much heavier weight than pytest to set up a test: you need to write it as a class, you have to inherit from the unit test classes etc etc. All this seems like a big disadvantage to using it in videos. Plus isn't it far less popular than pytest? What led you to choose unittest?

edit: oh, nvm, I just realized you probably chose unittest because it's a Python builtin. It's funny that almost everywhere I go that references testing, pytest is listed first and unittest and nose later. It seems like, despite unittest being a builtin, pytest is far more common in the community.

Ответить
Jonathan Headley
Jonathan Headley - 29.09.2021 21:23

Love the videos! Keep up the good work!

Ответить
chromosome24
chromosome24 - 27.09.2021 08:45

how about like 2% coverage...

Ответить
Grated Yammonster
Grated Yammonster - 23.09.2021 23:52

In hardware design we have access to tools suites that can take test plans with requirements written in spreadsheets, and when writing unit tests you attach those requirements to tests. As the tests pass it checks it off on the test plan. Do you happen to know of something similar in Python?

Ответить
SelimRbd
SelimRbd - 17.09.2021 14:47

Hi Arjan, I'm having trouble running "coverage" in a setup where you have your package code and test code in different folders. The "vehicle_info" package is not found (nonetheless it works correctly in vscode). Any tips for using the "coverage" library in a different setup than this video (I believe the most common setup is to have test files and package files in different directories ?)

Ответить
UNgineering
UNgineering - 26.08.2021 23:41

Excellent summary of unit testing and TDD!
Although, personally, I prefer to write one unit test at a time and pass it before moving on to the next one.

Ответить
T. Neulaender
T. Neulaender - 16.08.2021 11:29

Mutation testing can bring you a lot closer to 100%. But for non-trivial applications I doubt, that we'd ever reach true 100%. Of course 100% line/statement coverage, but not true coverage.

Ответить
Robert Brummayer
Robert Brummayer - 09.08.2021 21:12

Hi Arjan, thank you for your excellent video. Some comments: 1) As others already have pointed out, you really should not dismiss random testing for unit tests. With a fixed random seed, you can have determinism in regression and release tests. I would rather say, random testing is an essential testing technique for non-trivial software and multiple state-of-the-art variants such as "property based testing" exist. 2) There are many coverage variants such as path coverage, branch coverage, condition/decision coverage, etc. It would have been good to point out that you talk about line coverage which is a rather weak coverage metric. 3) Personally, I think line coverage is often overrated and if developers focus on having a high coverage too much, they tend to write poor tests that do not really verify the functionality, however simple increase the coverage number. It is good to find verification holes though.

Ответить
Leif Poorman
Leif Poorman - 05.08.2021 17:29

Certain kinds of randomized testing have their place (even in non-medical device code). For instance, property-based testing, as exemplified by the Hypothesis library in python, lets you generate data according to a spec and then assert that the result of a piece of code obeys some properties. But the data spec and the properties are usually only discovered once you write a lot of manual unit tests, so what you've said here still applies. :)

Ответить
Paul Johnson
Paul Johnson - 05.08.2021 13:51

Testing can show the presence of errors, but not their absence.
–E. Dijkstra

Ответить
shadycraig
shadycraig - 29.07.2021 00:36

Mutation testing can help to find issues with tests. The test framework will subtly modify your application during execution and check that your tests fail.

Ответить
Sven van Crombrugge
Sven van Crombrugge - 24.07.2021 19:15

I really like my randomized data. You've made a good point though, I gotta overthink that.

Ответить
Ervin Arnold
Ervin Arnold - 23.07.2021 07:46

Thanks a lot, fellow SDE!

Ответить
James Washington
James Washington - 22.07.2021 11:36

Just subscribed to your channel. You're helping me take my Python game to the next level! Learnt alot, keep on throwing out content like this please!

Ответить
Daniel Sandberg
Daniel Sandberg - 22.07.2021 04:51

I would like to recommend PyPI (pitest for python). It's a mutation framework that runs the tests, then changes the code and runs the tests again. If no tests fails the second time around, it is recorded as a "mutation that survived" and it will fail the build.

Ответить
skl9942
skl9942 - 18.07.2021 18:13

Your videos makes me want to sneak away and secretly code during the vacation with the family. If you have any tips on how to pull that off while still staying married that would be of great help :)

Ответить
Andrew Wall
Andrew Wall - 15.07.2021 19:23

Hey Arjan. These are great videos you are producing, however, I missed the part where you described "test-driven development". Perhaps you could do a dedicated video on this topic.

Ответить
Ahmed Alhallag
Ahmed Alhallag - 15.07.2021 03:16

He is the real MVP

Ответить
Dave Langers
Dave Langers - 14.07.2021 12:24

"Make your unit test 100% deterministic"
Alrighty!
But then generating thousands of random test cases starting from a fixed RNG seed should be preferable over just using one test value, right?

Or would you argue that is more prone to introduce the same bug in your calculation in both the main code and the unit test, since the test value is (likely) calculated dynamically as well?

Also, would you agree that testing cases that are "close to" edge cases is advisable? E.g. here, testing tax exemptions that are just above and just below (and equal to) the pre-exemption tax amount to be paid?

Thanks for this video; I'm in data-analysis where there isn't a lot of versioning, but I'm still gonna add unit-testing to my Trello templates.

Ответить
Aleksa Gordić - The AI Epiphany
Aleksa Gordić - The AI Epiphany - 21.06.2021 17:11

Nice video! A quick note on your advice never to use stochastic tests. It's awesome if you can avoid it (obviously)! But since I have an electronics background myself I can tell you that most of the digital circuit verification is based on randomized tests. Once the number of possible code paths starts exploding you have to resort to stochastic code analysis. Same goes for very complex software. Certain critical applications like code that flies airplanes and runs on critical medical devices obviously needs to obey to a much higher standard.

Ответить
Muhamed Abd El-Rhman
Muhamed Abd El-Rhman - 31.05.2021 12:34

Great video Thank you <3 <3

Ответить
Daniel Ellis
Daniel Ellis - 08.05.2021 21:20

Great video, thank you for explaining how bugs can exist despite 100% coverage.

Ответить
HampersUK
HampersUK - 19.04.2021 15:11

A great video as always, Arjan! Thank you.

Ответить
Talha Amir
Talha Amir - 17.04.2021 02:10

You Videos are awesome man !!!!

Ответить
Gregory Zhang
Gregory Zhang - 16.04.2021 05:52

randomized unit test should have some use case I believe

Ответить
Quiagon Jin
Quiagon Jin - 24.03.2021 20:24

Great video! Sugggestion: Can you turn down the like/subscribe sound effect? It was a bit loud

Ответить
Vyxx
Vyxx - 04.03.2021 04:58

100% video coverage completed - 1 bug detected: the software development elders did not want to be mentioned.

Ответить
Reuben Vandezande
Reuben Vandezande - 27.02.2021 18:06

Great video! When you pull up the html.index, do you do that inside VSCode (and what extension is that?) or is that just in your browser?

Ответить
mostafal1994
mostafal1994 - 27.02.2021 02:25

Another quality video, thanks Arjan 😊 A small tip: instead of having to define your vehicle object for every unit test, you can define it once using the setUp() method under your test case class as follows:

def setUp(self): # Camel case required
self.v = VehicleInfo("BMW", False, 10000)

You can then refer to self.v in all of your tests, and there's also a tearDown() method if needed

Ответить
Blueciffer
Blueciffer - 26.02.2021 21:16

Great Video!

Ответить
Rishan Riyal
Rishan Riyal - 26.02.2021 20:39

Please be kind enough to do a OOP video on python for developers whore are using other stacks.

Ответить
Metallo Devasto
Metallo Devasto - 26.02.2021 20:29

sorry if it's a dumb question but what does it mean on the method that "-> bool" because i never saw using arrows unless programming in R

Ответить
Max Delay
Max Delay - 26.02.2021 16:13

This is great, but I’d love to see how to completely cover functionality of an entire API! This includes API error handling, input validation, lower level database integration functionality and the business logic surrounding all this. Obviously testing the entire API call results in some seriously hefty tests and mocks so it’d be great to know how to split this out?

Would you unit tests the lower level functionality, and test the api layer independently of this lower layer by mocking the lower layer call?

Thanks

Ответить
Patrik Wiklund
Patrik Wiklund - 26.02.2021 15:39

I really appreciate your videos Arjan. Great content. I predict a very fast growth for your channel. Keep it up. :)

Ответить
F W
F W - 26.02.2021 11:25

Why do you use comments above the function or method definition header and not docstrings?

Ответить
rammsund
rammsund - 26.02.2021 11:04

Awesome job with this tutorial series Arjan!

Ответить
Formulka
Formulka - 26.02.2021 10:22

another great video, but that semicolon almost gave me a heart attack

Ответить
Hasibuzzaman Tonmoy
Hasibuzzaman Tonmoy - 26.02.2021 10:13

Your videos are sooooo good, man! It pains me to such few views and subscribers

Ответить