Unit Testing by Example

Video in TIB AV-Portal: Unit Testing by Example

Formal Metadata

Unit Testing by Example
Title of Series
Part Number
Number of Parts
CC Attribution 3.0 Unported:
You are free to use, adapt and copy, distribute and transmit the work or content in adapted or unchanged form for any legal purpose as long as the work is attributed to the author in the manner specified by the author or licensor.
Release Date

Content Metadata

Subject Area
Everyone tells you that you need to test. You know the theory, but you don't know where to begin. What to test? What cases to write? Through realistic and pragmatic examples, this presentation will take you away from var dump and ease you into the testing business until you're ready to do TDD. All this without losing sight of the tight deadlines. Anna Filina
Point (geometry) Suite (music) Boss Corporation Programming language Execution unit Presentation of a group Freeware Code Software developer View (database) Open source Stress (mechanics) Unit testing Line (geometry) Software testing Software testing Object (grammar) Window Task (computing)
Web page Point (geometry) Slide rule Suite (music) Game controller Functional (mathematics) Code Confidence interval Direction (geometry) Multiplication sign Execution unit Control flow Function (mathematics) Mereology Theory Number Element (mathematics) Software bug Mathematics Cuboid Software testing Code refactoring Integer Thumbnail Condition number Social class Form (programming) Physical system Decision tree learning Computational number theory Software developer Projective plane Expert system Database Bit Unit testing System call Discounts and allowances Message passing Word Telecommunication output Software testing Right angle Object (grammar) Resultant Renewal theory
Point (geometry) Functional (mathematics) Linear regression Observational study Code Parity (mathematics) Multiplication sign Maxima and minima Water vapor Function (mathematics) Mereology Theory Element (mathematics) Power (physics) Number Mathematics Operator (mathematics) Personal digital assistant Drill commands Software testing Uniform boundedness principle Maß <Mathematik> Addition Default (computer science) Linear regression Computational number theory Forcing (mathematics) Cellular automaton Projective plane Content (media) Sampling (statistics) Code Bit Total S.A. Line (geometry) Software Estimation Personal digital assistant Calculation Order (biology) Statement (computer science) Video game Software testing Summierbarkeit Right angle Object (grammar) Freeware Simulation
Point (geometry) Building Functional (mathematics) Computer file Code Multiplication sign Decision theory Set (mathematics) Function (mathematics) Client (computing) Rule of inference Twitter 2 (number) Element (mathematics) Product (business) Mechanism design Spreadsheet Bit rate Single-precision floating-point format Quilt Software testing Thumbnail Task (computing) Execution unit Touchscreen Linear regression Forcing (mathematics) Consistency Interface (computing) Projective plane Content (media) Data storage device Database Price index Multilateration Arithmetic mean Process (computing) Logic Text editor Quicksort
Functional (mathematics) Pixel Implementation Presentation of a group Computer file Code Modal logic Function (mathematics) Theory Product (business) Software bug Goodness of fit Single-precision floating-point format Cuboid Software testing Error message Game theory Social class Focus (optics) Key (cryptography) Interface (computing) Software developer Projective plane Maxima and minima Database Line (geometry) Library catalog Cartesian coordinate system Product (business) Electronic signature output Right angle Momentum Object (grammar) Reading (process) Row (database)
Personal digital assistant Multiplication sign Software testing Function (mathematics) Freeware Exception handling Focus (optics) Error message Physical system Exception handling
Boss Corporation Code Multiplication sign Software developer Code Online help Unit testing Mereology Estimator Process (computing) Bus (computing) Software testing Software testing Mathematical optimization
Complex (psychology) Code Kolmogorov complexity Projective plane Code Total S.A. Unit testing Computer programming Permutation Word Mathematics Message passing Personal digital assistant Software testing Software testing
Personal digital assistant Block (periodic table) Logic Code Decision theory Sampling (statistics) Software testing Line (geometry) Mereology
Point (geometry) Decision theory Software testing Branch (computer science) Diagram Iteration Loop (music) Product (business)
Multiplication Multiplication sign Set (mathematics) Total S.A. Peg solitaire Theory Product (business) Product (business) Vector potential Tablet computer Process (computing) Calculation Software testing Right angle Position operator
Point (geometry) Slide rule Complex (psychology) Parsing Code View (database) Multiplication sign Spiral Water vapor Proper map Machine vision Software bug Permutation Number Strategy game Well-formed formula Term (mathematics) String (computer science) Single-precision floating-point format Touch typing Software testing Mathematical optimization Installable File System Software developer Content (media) Code Sound effect Variable (mathematics) Proof theory Word Personal digital assistant Calculation Strategy game Computer science Software testing Right angle Game theory Object (grammar) Cycle (graph theory) Quicksort Writing Resultant
Trail Scheduling (computing) Multiplication sign Virtual machine GSM-Software-Management AG Client (computing) Food energy Front and back ends Frequency Intranet Robotics Term (mathematics) Gastropod shell Software testing Associative property Task (computing) Boss Corporation Arm Projective plane Data storage device Bit Unit testing Word Process (computing) Query language Factory (trading post) Summierbarkeit Right angle Arithmetic progression
we so from my point of view it's currently around midnight so if I can stay awake you should be able to stay awake army so unit testing by example on a test is typically found for about a day then grows to a few hundred lines of code and then your test becomes spaghetti and then you realize at some point that you just added more work to your plate that's how most people feel at home most bosses feel about unit testing and this is why they like it know and then you get to the point of doing the test and the deadlines are coming and you just throwing the testing out the window so my name is an affiliate of a developer and so on and the problem a teacher and an adviser and I come from Canada my objectives with this presentation is to make their use in testing for you more enjoyable than it used to be make it useful and reduce the pre really stress and I'm going to show you examples in PHP but the advice is also good for any other programming language as well and it's quite general so it can be very enjoyable in facts and so on I often see test suites does have a lot of tasks that but they don't do anything very useful so I will try to make it more meaningful more useful so that you see the point of writing them in you are compelled to write a so pre-release stress what is that so imagine it's Friday afternoon and you have to release and something goes terribly wrong and I have to stay up until midnight to fix it and it's it's very very frustrating and then you have this feeling in your stomach that you're like 0 I don't think I'm going to go anytime soon and and now everything is exploding so it's some very nice feeling and raise your hand if you ever have to release on Friday afternoon and it didn't go well alright so about half of you raise your hands alright so let's fix that because it's not
only damage efforts I just takes a lot of practice so yeah you don't become an expert on I don't expect to jump into unit tests and b can be an expert in exactly where you're going with it you have to start somewhere and build on that and progressed slowly and then in the end it will become really good and it will make a lot of sense and then your call will be of great quality in you can release on any day with just 1 click and is going to go find so some some of you have possibly you try to write some tests and gave up because you can see the advantages of them and some of you may be haven't tried with all of you at the end I hope that you will be able to to want to write some tests to try the series of and this like what what works so you don't start with 100 % coverage don't fool yourselves that you're going to go there and you will write a test suite is going to have 100 % coverage right from the start and this is what we should strive for what is not somewhere that you should begin you should begin with something much smaller so that you can you can write your tests and then get used to them and understand how testing works and how was the relationship between the tests and you're cold and then the and then you'll be able to but to moving in a good direction and then increase the coverage because now you know that what you're writing are quality tests so when you test without automation it goes about like that but you have to have a new feature and then you go in and you test that I you click here you could some input there and it works then you add another feature in the new test set manually you try few things which also have to test the other thing before it because you you don't know if what you we uh that feature that you wrote may be changed a little bit in 1 class and then it has an impact on the rest of the obligations theory test everything we have another feature another than you have 50 features that you have to test under various conditions and sometimes becomes a lot of work and also that the human eye cannot see everything precise of say you have on your fetching something from database and you supposed to have 65 elements on your page legal thumbnails but similar there 65 you have to count them if you're doing it manually right you have to count them by hand 65 if they're 66 you might not miss it and if sometimes change that happened in the code is now making 66 elements appearing might not notice because you don't want to call it repeatedly and and you can even make a mistake in counting because there's just so many the computer can go out for you that's the whole point of automating is that you don't have to inspect the output visually because visually can miss certain things and I know what happened to me where I I would write it sets and then in so that the output of this it was some JavaScript and there was a test and was supposed to show something on the page and he was showing something else so that doesn't pass much what it's not supposed to be like that so I go to the to the to the page I know is that it says as slide 1 hour of not the number so there was this mistake and we would not have noticed it at any point because you know the characters are more or less similar to the 1 out of something and the brain just fills in the rest is like when you read words and the letters of ah backwards we don't really notice that the word is misspelled because our brain completes the picture and that's the problem with the rain and this is why we use the computer to not have these biases so the and also you're afraid to to make changes to your call this like you walk on thin ice and you're free to breathe because if you make the wrong move everything's gonna break on the you know that beautiful through it's going to begin the world and so the units they give you or just Automated Test in general the you this confidence to move forward because you know that the the ground walking on is really solid and then as you gain confidence is no longer the cold controlling you it's you controlling the cold and the cold does exactly as you tell it to do and the united freight go into bigger refactoring projects and stuff like that
so it's a lot more fun so there are many opportunities to write text and I will show you step by step how to spot these opportunities and what kind of test you can write at that stage so think of it as the 4 stages toward the so the 1st and easiest step is when you find that you find so for example and when a user enters 0 . 1 in the quantity of your charging the customer 0 . 1 times the price which is incorrect because it's impossible to basically giving them a 90 % discount to know 1 that makes all sense it might mess up your other systems as well so you need to to make sure that anything that comes in is either validated world written rejected or may be transformed in some way so what you do is you would instantiate the cart item object with an item which is currently gaining and that 30 dollars and he said the quantity at 0 . 1 so he sentenced to the wrong 1 so that you can assert that it it actually fails so when you say a certain equals 1 and of get quantity because you want when you wanted to return once say what you want to do but then the actual thing is going to fail this is the 1st step why because if you if you if this was passed then you would think well something else is wrong right so you have to make sure that you have to confirm that this is actually about this is exactly what is causing the box this is why it has the feeling scenario once it fails what you do is you go to recall and you make a change so the change you made it is and and I just show you a part of the function so when you get there you want to set the quantity you know you apply function to rounded up to the next integer so he gets 0 . 1 you get you get what if you put 2 . 1 you get 3 so by doing this now if you run this test and 0 . 1 it will be equal to 1 Indian right so 1 0 . 1 comes in 1 comes out in this test will pass so this switch from feeling to failing results to success results to passing results this is what you're looking for and you do it when you find bugs um so yeah why would you write a test for something that is so some people also is because it provides a form of documentation so it's it's not obvious to always write comments as to why you put this ceiling here why would you why would you run it up well that's because of we want to make sure that whenever we put 0 . 1 we get actually was so that without having any kind of comments that test both makes sure that there's no air but at the same time provides a form of documentation because then somebody will try and look for so for all the functions that test the quantity and find this the other developer after you will find this and say OK that makes sense and this understand why it has been done this way so it's also form of communication between yourself and other developers and future developers maybe in future you so you write some code and then a week later you forget what why you roll things in a certain way and this reminds you alright that's because we have this fog so not only does it remind you of why does that but what about was which can be very useful
right so before we move on let's just talk about some vocabulary so what we just saw here is called regression testing is we make sure that the cold that you run into right to date is still going to work tomorrow this is or at the college affixed to their is not going to be broken tomorrow so later if you make any other changes to the function you want to make sure that it keeps behaving in the same way and the easiest way to do that is to write a test and it's just 3 lines of code it's
very straightforward another opportunity to them to test is when you are about to improve existing code you want to make some changes to it so I can this scenario you you want to add additional cold which were afraid to break what is already there so what you do is this is this scenario I you want to make shipping free for waters over 40 dollars so if somebody orders below that's the shipping and so on much 12 dollars they think answer the shifting dollars and then if you are a if not then you want to make sure that the shipping is free if it's about 40 or above then the shipping history so you write this as you add 2 items and you make sure that but this this fails it will fail because of their in this case it will In this case it will pass so we should also right they're feeling because for that but stock not 1st when you write this it will fail because you have made the change and then once you make the changes to the shipping calculation then I will start passing so 1st every order on which they can begin shipping function always returns 15 but what you want is to change that behavior so here it will be a failing failing scenario so once again we make sure that the shipping is 0 and the get totally 60 and now we're want to change our get shipping function where we of we put an if statement and we check for the total so if the sample is less or equal than 40 essay greater or equal than for a return 0 so if far order is greater than this amount of free shipping if not the default shipping is 15 and can add additional calculation based on the destination or to provide the user with it you want express shipping you can add that functionality will make sure that if it's all a certain amount it's going to be free all the time so now that you know if you run the same test that you written before it will pass and this is what you want so right test both cases so mountains the free shipping but also test the other case where the shipping is not free because if you make a mistake force it's a simple example just to illustrate how it works but in some more complex called you might make a mistake and free shipping to everyone so that even if the person orders for 1 dollar you still get free shipping so you losing a lot of money so to avoid that make sure that you add another test where you will make a new test for something that is below 30 so the quantities once a one-time studies theory so the shipping will be 15 and the total will be 45 which 30 plus the ship so so he had the the the idea is to to DB scenarios because we have an if statement and I'll explain that a bit later on why this is important so we learn how to write tests after most of your code is implemented which is pretty straightforward as probably something you will do when you come into a project and you see not test you will have to write down but once this is done a new starting completely new called while you write the cold you can also write the test so simultaneously so what you do for example if you are writing gets old function and you want to start applying taxes you start adding this these taxes and usually you would after you've gotten your applicable taxes you might want to as output the content of the taxes are a what it contain to make sure that everything else is is not going to fail because of the wrong wrong so do an output then you inspect the contents of which would look something like that so this is a part of odd number of of that taxes erase it contains basically 2 elements and each element contains the name for the tax that will appear on the invoice and the percentage so in Quebec we have 2 taxes we have the federal tax that is applied which is 5 % and then we have the provincial tax applied in addition to that which is 9 point 9 75 per cent which is a weird number of it this is how we are it was essentially a funny story because it used to be compounds and in the sense that at 1st they would take the sum total and then adds the 1st tax and taking all of that and then apply the other text which is like a toxin attacks but then they'd be realizable the software and is having trouble supporting those you know different taxes where in most they pretty much everywhere in the work world it doesn't exist and just in Quebec so they decided to make life easier for e-commerce in Quebec they decided let's just let's just change the value of this instead so it used to be a thick line point 1 0 9 5 1 1 . 5 per cent and and then they just changes so that is the total is still the same but at least you no longer need to compile you just take the sum total multiplied by this supple multiplied by this and then everything together will give you the tools so here's there's a little bit of tax history in Quebec still when you write the code instead of doing this out but I'll just bring you back to the cell but the problem with this is your once again visually with your eye inspecting this and making it as an assertion you're saying OK this was good but your 1 single muscles but maybe it's not good right maybe for example say there's no 0 here so what happens so it's 0 . 99 75 that's a problem because you might not notice it's with your eyes but if you tell the computer to look for that value to computer will tell you know this is wrong you have the right value and it's very it's a very it's a mistake to make I made this mistake 1 so what we do here now is we instantiate and you can't we get all the applicable taxes for this customer and we assert the internal power that accelerates all not an object or anything else so that all the subsequent operations will not fail and then we make sure that it contains 2 elements we grab the 1st that's the 1st element and we assume that it's equal to 0 . 0 5 this is useful right and so if it's anything else then it will fail so now it might have that the
advantages of this approach is that In all of these tricks I showed you that you can use while writing after writing cold and while writing the code allows you to write more tests very quickly because they're so obvious basically whenever you are compelled to outputs of the content of an array or relate to output of value to your screen or to along instead created test so that's the rule of thumb whenever you're about to do this instead write a test and that will remain forever so that later if it breaks you don't have to to do the same barred them you have to help with the same value all the time inspected visually and if under certain scenarios you might have all maybe taxes that's pretty simple as maybe 2 or 3 but for other things you might have 20 elements and you have to look at them every single time and it's very time consuming so writing this task which so but we may be without practice takes 20 minutes but with enough practice mean takes 20 seconds and with those 20 seconds you saving a lot more because those steps you will be executing them once in a 1 2 3 times per maybe per minute because you can hope you're on your test splits into this seeming mechanism of your editor and then every time you save any file you can rerun your entire tests we just pretty quick so you can you can write more tests and they will become very easy to write and you will know thought never fall too far well why my saying this imagine if you are climbing a mountain and there's always a risk that you will follow and you will die so what's the climbers due the plant a little anchor then they put their rock through it in this way if they ever lose their grip they're only going to follow as far as the last anchor in these are what regression tests are it's basically you're planting and so you know that you will never fall below that point because the test will indicate the 2nd anything is wrong so any keep building them so as you go forward you build your test test that progress some final how to while you called but how about writing it before is it even possible how does it may even make sense it will it will be difficult at 1st and you will have to follow these 3 steps before you get into the force that which is testing before so that he can get enough practice an understanding of how tests work and what makes a test useful and also how to write them effectively I'm not writing to me test the the is there such a thing as writing to me test meaningless I thought I think it's sort tweet once in a only getters and setters are tested up and down but you know testing together in a set means nothing because then there is no business logic in there so what we do here is 1
example let's say you want to pass on data from the season it happens all the time so you're building your online store and now you're almost done with your project and then the clients as well instead of putting all our products 1 by 1 from the interface lets us I have this spreadsheet I can export indices the and then we can dump it into our database may have to write this process and you have you have to know how important read the data I could pass validate make sure that there's no inconsistencies and then and stored into the database but how are you going to read that's rate is it going to be so in PHP we have filed get contents is that the function will use I no and the thing is with the things that you don't have to make that decision right now you can postpone and that decision until later show how so all you
know is that you have a file name and that you want to have an array that contains certain certain items at the and that's what the pastor supposed to do so the catalog imports can look after but what you do is instantiated in you pass from C is the in which method and the departs from Susy is going to read the file doesn't matter is even the file will know maybe it's a database record that is in this is the key it really doesn't matter can you can extract that you don't have to think about that what you have to think about is how it's supposed to work all you possess right now is a file and what you want from from that function corresponds to is you want to have an array of products and you have to that it contained 2 products and you wonder products to have a name and a price so you want to make sure that there's no knowledge there that the keys exist and there's no possibly can says for the values make sure that they do not empty so you can do all that and by doing it this way you and you will end up with more elegant code because at 1st you're gonna run it is going explode because the classes exist is the right the class and you write the function signature and then just return now in the signature and then your assertions that are going going to start to fail so annihilate OK well I really have my class and then I'm going to start writing things and they're going to us open this file and pass it and then get into into disarray and then as you progress so you will create your season you'll have to set up the infrastructure for this test to pass you have to write the necessary amount of code for these tests to be positive and once these tests are positive you're not that's a great thing so it will it forces you to think about the interface pixel so interfaces the input and the output not about the implementation and you were about the implementation the minimum amount of implementation of the main lines of code necessary for this to pass so you are writing less code which is more structured more elegant because your testing all your function separately so if 1 function fails you'll know that is precisely this function and not 10 steps down the road because what happens often is that you have an error here but it's not because of this here it's because the input that was provided is garbage because this function is not working right or maybe this function was called by another function which didn't do some something properly right so by isolating all these functions and testing them completely separately you can achieve that and I won't get
into the whole concept of Marxist but if you want to know look up mocks when you're ready and the marks will enable you to isolate things that still have dependencies so sometimes to instantiate a class you need to give it another object and you can you can obstruct that's by writing a mark so that's a that's a different topic it's too large for this for this presentation so and and the thing is you want introduce any bugs because if you're right all your tests in advance you're you don't write any bugs in the code to begin with early she so there this that the when you say that you have no boxes as far as your tests are good so if you world good test then you will have a bugs and sometimes it happens it happens that you finish and application and nothing goes wrong and it happened to me when I finished I was writing an API and was pretty straightforward it's just an API so would you know read data from from adjacent input and then stored in a database and then outputs of stuff and I will test for that and I give it to the front-end developer to and to develop to develop an angular GS application on top of this API and everything was working fine no no bonds and we deployed its it took us 4 and 6 in theory 16 weeks well 6 weeks to write project in the project now after 6 weeks he was not and it's been almost 2 years not a single complaint great so focus
some somewhat tips for you don't just think about how it's supposed to work also think about how it's not supposed to work social you earlier about having no test test if you know was 0 . 1 else pretty straightforward but later you have the shipping fees and then OK so we know we're supposed to have free shipping but we're also in some cases supposed to not have free shipping so test all cases the positive and the negative access to look their best but what happens if something is provided on all so basically test for all of these exceptions that can happen so that your system will be more robust and will not continue executing and then explode too late so the earlier you can you can output the error and the quicker you know that the problem is because you give me an hour and then focus on realistic scenarios so as I said a get you're not supposed to test so here's an example which
is a total equal 5 then you should assert that this not now because it's pretty obvious it's not realistic that something between those 2 would go wrong you could but do you really want to spend time on that and if you start testing all of these very obvious things you will have thousands of testing a sweet and they will be pretty much useless and you will have to maintain them as well it's going to be very annoying so is there a
couple of of the different steps in this testing takes practice you have to write tests when you see above but you can write tests when you are improving code you will write tests as you are about to write new code and then even before and make sure to test the unexpectedness being here I unexpected scenario sorry and the thing is 1 of the obstacles to sell the unit test your boss is
that it takes time they realize the testing is something that takes time so they will say well we don't have time for testing but the thing is do you also tell them well I'm going to take that much time for the body you don't tell it's kind of part of the development process will testing is supposed to be part of the development process this is that not everybody does it this way but if you were to ship called without debugging it it will fly so why do we should go without testing is pretty much the same that there are about this is that we don't know about that so it's the same as the binding of that testing is actually helping us would debugging if we're writing the test early enough the help of the bus so we shouldn't sell them as something separate you should include that in your estimates so when you estimate how much the future will take estimate the time for the feature for the performance optimization for the tests would be debugging all of it together and for the time to clarify requirements all that and so yeah and
then there a bonus you know once you have enough practice it will be faster to write code if you have to so test + cold will eventually become faster than just code so at 1st test like you're adding that at the end or at the beginning you add more work but as you get really good at it the tests are going to guide your programming so well that is actually going to be much faster and that's the case for me I should projects and 4 or 5 weeks typically so not months or years that's because it test everything before I II and forward it's counterintuitive but that's how it's supposed to work so give them a fair chance now I talked about cyclomatic complexity or how to test and know different if because you have and if you're supposed to write to test cases is that works I'm here
In all the total has to be this 50 otherwise we return here we only need to answer if you will need to write to test because we have if but because you know basically means how many different paths the cold could take is there's an if it can take is that this method this the 2 it's possible execution paths which means that we need to unit test for that OK so as cyclomatic complexity is a is a fancy word but mostly means how many asking your code take it's not the permutations it's just so every if even if it's inside the if it's only going to add 1 more pass and it's just mathematics so it's useful because nice success with the 100 dollar some subtotal then if you have a
sample of 100 then you're not testing the last line it's not tested in this case it's pretty obvious but just to illustrate that the thing if you have some more
logic in here then you would not have test the whole block because you would have returned there and if you test with something that is below 50 and then you test this part but not what's inside this code would have been left and tested and their tools that allow you to see which passive and
taken and whether everything has been covered by the by the test this is called code coverage for each decision you make in there it's a loop or and if it adds additional execution about
so this is just a diagram very fancy so Lopez that is a decision branch but White House at the decision well it has to break at some point right so there is an implicit if there's if inside of it that you don't see but it actually executes and then at some point it has to decide that it has to stop so to test if what I do is I typically right to test 1 with 0 I tends to uh 0 0
iterations and 1 with multiple iterations will show so here we have about OK
so the considered gold and you have the product will open which you're adding to the full well you later check for that and because we didn't know this will throw you notice because total has not been if you have 0 products then the total would not have been defined and then told doesn't exist here so in PHP unless you you put total equal to something it's not defined so it's gonna throw you notice and then you few tried to use that somewhere else in calculations and there's a potential for failure so you right that let's fix that and so I have a have a blank slate for some let's fix if you put a toehold equals 0 so nice to rewrite the test with 0 product with no products of all an empty array this is not going to work well so you think because if you tried with only 1 product you'll still have about here and you may have not have noticed but it's total equal so when you move you don't actually add to it you just keep reassigning basically you want to miss and you would know test with 1 product you're going to get a false positive that's gonna go yeah sure it works your product price was single theory and the quantity was once we are sure it's the tallest very great great job you're not know but
if you have a set of products like that then the toll should have been 16 but if not that's why you have to rights with multiple items so that you can iterate multiple times to avoid problems such as this and other similar issues so we have to be bulletproof he needs a test for is your products and another test for multiple products and that's a my name is on the
inorganic do PHP JavaScript and another development I fix bugs and perform lot uh and the performance optimization workshops and testing Symphony Angular JS CPIs and I advise on testing strategy and I do a lot of legacy code and do you have any questions I will between the slides by the way the questions what can you do about it so OK yeah similar to 1 of the ball game variables were also the people the will of the artist we want you with them of the world removal of the log
OK so the question was whether and it's good practice to have 1 assertion were is it OK to have multiple assertions in a single test case and I would like to do that you just 1 assertion but I could never practically gets that to work because then I would have to be instantiated my object repeatedly so that I can test will is the summary will if it's on the right and this is that like in case of on the right want this and I can I can see right away OK son the race for effects that we have the same test i have to run it again to see if it passes but I'm running my entire test anyway so permits sort of mediation is says that you shouldn't have to test to many things you should have to test basically 1 execution path and that should be good enough at least 1 from my point of view it was all over all right you the world would be the that writing is to want this vision thing to the all of the word which the 1st of all you want the the whole go along the whole which is the forward all of it so the question is so the question is if we have nested IFs would we write for test cases because we have 4 permutations and it's not permutations I know it's not intuitive but mathematically it's really just to pass a three-pass sorry 1 world you will of the last time you all as right so if we go to wikipedia cycle my complexity says pretty clearly exactly how the how the number of tests relates to the to believe number of paths and how to calculate the parses a formula very can use can literally just counter if such and such and apply the formula and get the result you know the the you know it the all all proof of the the world the the OK so the question was whether you would tests in terms of you know when it's an integer and such for but what's the content right all right but there so so the question is whether we're testing the actual contents our are we testing in terms of computer science I would say that you should strive for the computer science except when it touches numbers then you have to make sure that the calculations of proper work sometimes give me things are not truncated there with this scary or something else in the strain it doesn't really matter but it allows you to know that it is the 1 that you provided here basically it's a way for you to if you have a certain items that you were sorting and then you want to make sure that the 1st 1 is the 1 that you expect then basically that the this string that put their identifies that this is the 1 for all it is the that that if you're going to have the right right so all so basically what were confirming that yes and then because we can have different waters we have to make sure that things if you order matters then yes we would says that this is and this is the right thing that we're getting here and this is the right string and not the other 1 so he that were spiral more Diablo then it's not Diablo that appears on top that's it's really scary so now you know where they but sir
question back now 2nd European I'm their so circumstances what I would consider circumstances to remove assertions an well I will write them in the 1st place really I guess if well yes it's it's I don't know I really don't know the answer maybe we can discuss some more yeah practical scenarios and then I can better understand the situation it's it's hard for me to to imagine we also it's of the all right so that the question is if the boss would sanction 4 months of testing periods then how would accompany go about introducing unit test and just introduce them gradually I would say and whenever you try to do a big like russia and try to do that all at once it's quite difficult because then you're just writing tests and you're not writing something that the client we think the client wants the client wants quality of course but the client doesn't realize because the they have you know schedules the deadlines and the 1 to generate value they want to conquer new markets like until we understand that so they might not everybody also understand the concept of technical debt which is a completely other topic but the idea is that you can you can go slowly largely like that say you want to buy a house but you wouldn't want to wait 25 years to amass all the money so that then you can go and buy the buy the house you'll want to live in the house right now so for the sake of the client basically you can give the client what they want which is features but at the same time try to introduce a little bit so make your monthly payments at the words that those unit test stores at that to reduce it progressively and eventually if you are able to produce tests faster than you are producing cold and then you will eventually cover not only being you call that you're right but also the old 1 you keep adding more and more and more and eventually it will be opaque it's a long term process but it's a good way to do that because you know arguing about it and having to explain technical that is can be a challenge so I can understand why doing it this way it would make sense OK so what is on the picture yet well it's automation right so this is like a robot putting stuff I'm not sure it's a stop for a cemetery exactly what these things are but a half a year I looks like it could be shells and yeah I I never really thought about it you just look like um so I was I had a big project with the uh factory for automating there not completing the task but also admitting that that's we wanted to improve their their processes so we're opening intranets to to simplify things and make everything more automatic anal tracking progress and such and so when I think of summation I was think about those machines because they have this robot that would cut a piece of metal precisely and so I just I was really cool so yeah this is my association with automation factories as any other questions Mr. wake OK so doing something to test energy query haven't been doing much of front-end testing arm and I'm thinking about getting into it but I heard about things like a so you shouldn't angular JS there's common Jasmine others also Caspar GSM leaders for JavaScript in general uh so yeah look at look at those and see whether the the are suitable for what you're doing alright well think you and and and have


  156 ms - page object


AV-Portal 3.21.3 (19e43a18c8aa08bcbdf3e35b975c18acb737c630)