Hi Andy, first of all i'm really sorry for my first comment at your channel where i wrote "Andrew" instead of "Andy"!, it is great information about testing, i just heard about Unit testing but never got this much information! Thanks Andy
Excellent refresher on unit testing! One small addenum to your video: When you created the should_create_tesla_make(), I think you should've mentioned that you wrote the test to explicitly test *only* the "Make" parameter of the CreateTesla() method, although you did mention that this method will require testing at least 2 parameters (Make and Model). Appreciate that you went the extra step by creating & running the should_create_tesla_model() test method as well! Thanks!
In response to the commentator who mentioned the “gibberish” comment…I think you need a more advanced and narrowly focused video…I appreciated Andy’s …”gibberish” as you put it! Thanks Andy, I used this as an intro for some beginner developers and it provided a clear, succinct intro for them! Great job!!!!
Like Andy said my organization does not do this so when i had an interview with another company, they asked me if i write unit tests, I said no, and they looked at me like I was some alien. So now I am here, thanks for the video!
Our devs have written in big letters on the board that reads "Write your tests first". Before they write the code they develop the test. It helps them ensure what they are building is well thought out.
I have not been in the hiring position...but if I was, I like that response and it would make me laugh. There should be more laughing in the interview process imo
This video was very helpful Andy I heard of Unit testing before but never understood what if was for and how it works. Now I have a better understanding of both. If you have references on how to learn more about Unit testing you would like to share I would appreciate it. Thank again.
This is a really helpful video! I've always heard this topic but never really known how to approach it but this is a really friendly approach to unit testing since it seems like a monster when thinking about it initially.
I don’t understand why most RUclipsrs(Andy included) don’t talk more about the importance of KNOWING algorithms AND time complexity. Because when you go on an interview in 2019 or beyond, companies don’t care about your projects or your github. They know at this point that stuff can be fabricated. Taking a code test or doing the White board interview is more important than any of this gibberish.
I had a job interview where I was asked two questions. First, in the Chomsky hierarchy of languages, what type of language is xml? Second, using the big-O notation, what is the runtime complexity of a dictionary abstract data type? Both questions related to what they did at that company. I thought the questions were kind of basic, and I answered them. I got the job, but I later regretted accepting it because of how I was treated by the Indians of the company. It was the last software job I ever had.
I think it would've been helpful for learners to hear that the use of interfaces does wonders for unit testing. Which would naturally lead to methods of those injected interfaces to then be mocked. Etc.
Unit Testing == Testing a single 'unit' of your code. That unit is as small as you define. Most of the time I've seen it down to the individual method or function level but it could be as small as a single statement if you really wanted to put the work into it.
Hey Andy! Thank you for hitting the topic. It helps with a better understanding how unit testing works and from the looks of your github. I was able to kind of understand how to setup the testing but not fully.
Memory Testing. To test individual class file with memory variable to make sure it can run by itself without fail. Validity of test data to make sure it can function within the code itself.
Wow when I watched this I thought how the hell would I do that for the thousands of lines of code I have? I guess what this is was a demonstration of just verifying that the correct output is produced by the input. Is that basically what "unit testing" is?
The key to unit testing is that your code is modularized. Testing thousands of lines of code is very difficult if not impossible. However if you had modularized your code to the point where you can test each module, now you can start to see how it can be possible.
I am taking a university degree they just threw material about testing .Guess what I have been stuck for days ,this video cleared a lot for me ..I kept on testing a function that connects to a database and ran into tonnes of errors
I needed to have an idea about 2 subjects, Angular and Unite Testing. And you talked about Unit Testing IN your Angular video. WHAT ARE THE CHANCES?! Thank you.
I would explain in this comment but this post actually does a terrific job of explaining it in detail: blog.pragmatists.com/test-doubles-fakes-mocks-and-stubs-1a7491dfa3da
Question, I've been researching employment in my area and I've come to find that unit testing knowledge is needed. The 6 major of Unit testing involve Mocha, Chai, JSHint/JSLint, Cypress, Jasmine and JSUnit. I'm leaning more towards Cypress because I code with Node, but also am learning Angular and React down the line. Out of the 6 I listed, which do you use and why?
@@AndySterkowitz tell me this when cops stopped you when you was driving under influence after a party! just kidding I know developers all enjoy responsibly!
Better late than never ;) I'm about to start my thesis and I picked this subject based on my boss's recommendation and found it to be very interesting. I was confused at first, nontheless, about how it worked, but this video was great for setting me on track. Thank you!
In previous lives, I used Test Track Pro by Seapine Technology, that company was acquired by Perforce and the product is now called Helix TCM, but the product was very powerful at the time, are you using similar things in your automated testing?
Both. In an application it can help ensure that changes made to existing code doesn’t break. If you use a continuous integration server you can have all the tests in your project run each time you or someone else commits to a code base. This will help catch so many errors before they bubble up into production bugs.
@@AndySterkowitz, thanks for the answer. But can you make video with a real example or something? Maybe I don't see why this is important(although I know it's important, :-)) because the example is too simple.
Unit testing has very limited usefulness for most web apps. 95% of the code that you write either interacts with the database or deals with the UI. And you can't unit test those things.
Would the units you are typically testing be more complex than what is shown here? The test itself is more complicated than the unit it is testing in the example.
Definitely. This is meant to be a super simple example. Real life modules will typically have more logic that needs to be tested through each individual test.
Note to any Developers: If your company is NOT implementing any tests in the codebase, please do yourself a favour and QUIT, you deserve so much than said company AND/OR suggest they implement some testing framework, if that fails refer to previous step. FYI, I have never been in a company that does NOT use some sort of testing framework whether it be Karma, Cypress, python unittest, Selenium, JEST, etc.
Terrible advice. Plenty of legacy systems don't have test suites and implementing them would take months which would be hard to justify to upper management. Plus as long as the money is good who cares?
I recently have had to use unit testing in a new role. Prior to that I had never used it and everything I programmed worked just fine. My personal opinion is that it's a huge waste of time. You want to program something, you program and run it. It crashes, you fix the code until it doesn't crach anymore. End of story. The more I stay in this software engineering role, the more I suspect this industry has invented a lot of additional stuff to delay the delivery of a product and waste the client's time. Apparently the purpose of unit testing is to ensure quality standards. Quality to me means the program works and does what the client asked, and does not crash when used. That can be achieved in a more straight forward way and faster without implementing unit testing. But hey, I get paid to do what I love: code. If that means wasting the client's time, let's chuck that up to a business decision.
I always remember when he got his first job. I was just like " he made it " and here we go I taught myself as well and been working for 5 months thanks
if i applied this stuff to the android app i've been making for work i feel like i would have to write about 300,000 tests... and the app isn't that complicated. how do you know which units to test or not?
So how do you know what to test? I guess if you have a piece of logic that accepts data coming from different directions? My biggest issue rn is writing code to handle when data is not there.
I would like to know response from the people who read this comment ,so If you have some time to spare, please answer my questions. 1) Have you ever been asked by your supervisor to skip the unit testing code in order to save time and push the code to production ? 2)Does your codebase contain broken tests from the past which was caused by another developer who did not bother to fix it before committing his changes to repository ?
Thank you for the video. I have one question, what if I have no mutch time to test my code? Here we are building apps in two three weeks, and I have no time to make tests. Can you suggest me something?
Maybe first discuss the layout and the basics of your idea like the basic functions, what type each function/method is going to return + basic components of your app before starting to code. After that, assign few members of your team to use this info to write the testing code even before writing the app code, while the other members write the app code. This way you will have two parties in your team runnning at the same time, one writing your app, and the other writing the test code. I am a CS student and this is just my suggestion. Please do further research. There might be easier ways since this is just an idea that i came up just now.
@@isMeStranger Thanks bro. My comment is 2y old so far and I've grown a lot professionally. What you said makes a lot of sense. My current approach is to write unit tests at least for the most important features when I don't have too much time
@@pedromassango Hello, thanks for your reply and for providing your current approach, it might be userful experience to know how people are working as programmers/developers as im graduating soon. Its good to see that you are much better at what you do now. Goodluck.
Thanks for the explain but i still dont get it. If i create a Tesla and within its constructor it uses the const char ptr "Tesla" to name it. Why should i test if its realy named "Tesla" ? I know that this is an easy example to understand but i dont get it. Its maybe the better way instead of put breaks or printf the Variables?
Instead of testing the app manually (running the app and putting it through different test cases) you can write automated tests that do the work for you. This is the simplest way I can explain it.
@@AndySterkowitz It just seems like a big waste of time writing the tests if you're just comparing variables. It does make sense though if you're working in a team and you have tests run whenever someone commits, that can be very useful but then you would have to write new tests for every single new feature you add, right? I don't want this to sound like I'm criticising it, I just don't really understand....
Unit test is useless. Ideally the unit test code should cover all possible scenarios and thus eliminate bugs. But most unit test code I've seen only uses one or two set of data. So passing these tests only means that the code passed the most basic check. Also there's the tedious job of fixing unit test code once the original methods are changed. This is particularly true in Salesforce development where unit tests have to be verified in deployment.
Awsome mate I'm here in 2021 I'm really committed in learning about how to host and code my own bot and server I have been trying to understand the language for months on end non stop 😴 I have been using the python progam to help me am I doing the right things
I've been a dev for 5 years soon and I still don't see why people get so hyped on unit tests. First of it shouldn't even be called test. It should be called business logic validation, because that's what the hell we are doing. Second. Why do these "tests" even exist? It's only there to validate the business logic and if you know the business logic and expected output then why would you need to test for it. It's expensive to write and maintain and it don't test user flows. It should be used in some cases but not all.
TDD is a thing but it requires a need for quality and it requires trust from the management. I can see it for zero interference once deployed projects like Subsea Wellheads but anything other than that it will probably be too expensive. Quality that can't be patched it very rare and that reduces TDDs value point. It works but it might just be a bit expensive. The world now is used to failing commodities. We are in the era of Planned obsceneness. Stuff won't last by design. Building something of quality is counter productive in a capitalist society. That's just depressing. Luv and Peace.
Does this give you a basic idea about unit testing? Is there anything unclear or that could have been further explained?
Hey Andy! Could you set more free time? There aren't any available dates to talk to you D:
If not, could I take your e-mail? cryptodecuisine@gmail.com
Hi Andy, first of all i'm really sorry for my first comment at your channel where i wrote "Andrew" instead of "Andy"!, it is great information about testing, i just heard about Unit testing but never got this much information! Thanks Andy
Andy Sterkowitz No times are available to schedule a career strategy advice call with you.
Excellent refresher on unit testing! One small addenum to your video: When you created the should_create_tesla_make(), I think you should've mentioned that you wrote the test to explicitly test *only* the "Make" parameter of the CreateTesla() method, although you did mention that this method will require testing at least 2 parameters (Make and Model). Appreciate that you went the extra step by creating & running the should_create_tesla_model() test method as well! Thanks!
Thank you for this video..
It helped me understand what is unit testing
In response to the commentator who mentioned the “gibberish” comment…I think you need a more advanced and narrowly focused video…I appreciated Andy’s …”gibberish” as you put it!
Thanks Andy, I used this as an intro for some beginner developers and it provided a clear, succinct intro for them! Great job!!!!
Like Andy said my organization does not do this so when i had an interview with another company, they asked me if i write unit tests, I said no, and they looked at me like I was some alien. So now I am here, thanks for the video!
Our devs have written in big letters on the board that reads "Write your tests first". Before they write the code they develop the test. It helps them ensure what they are building is well thought out.
Learning about this right now!
omg such good advice thank you!
Apparently "Oh yeah, I test the shit outta units!" isn't a valid interview response.
Haha #winning
I have not been in the hiring position...but if I was, I like that response and it would make me laugh. There should be more laughing in the interview process imo
response = "Oh yeah, I test the shit outta units!";
if (response != valid) {
findNewCompany = true;
}
😂😂😂
This video was very helpful Andy I heard of Unit testing before but never understood what if was for and how it works. Now I have a better understanding of both. If you have references on how to learn more about Unit testing you would like to share I would appreciate it. Thank again.
This is a really helpful video! I've always heard this topic but never really known how to approach it but this is a really friendly approach to unit testing since it seems like a monster when thinking about it initially.
I don’t understand why most RUclipsrs(Andy included) don’t talk more about the importance of KNOWING algorithms AND time complexity. Because when you go on an interview in 2019 or beyond, companies don’t care about your projects or your github. They know at this point that stuff can be fabricated. Taking a code test or doing the White board interview is more important than any of this gibberish.
I had a job interview where I was asked two questions. First, in the Chomsky hierarchy of languages, what type of language is xml? Second, using the big-O notation, what is the runtime complexity of a dictionary abstract data type?
Both questions related to what they did at that company. I thought the questions were kind of basic, and I answered them.
I got the job, but I later regretted accepting it because of how I was treated by the Indians of the company. It was the last software job I ever had.
They are just aholes . Continue in this field sir@@timtruett5184
@@timtruett5184sorry bud but us south Asians are smarter and better that’s why we take all your high skill jobs
Man it is so hard to self educate yourself lol glad to have RUclips lol
Thank you, Andy. You are a great teacher with much enthusiasm and passion for your work!
I think it would've been helpful for learners to hear that the use of interfaces does wonders for unit testing. Which would naturally lead to methods of those injected interfaces to then be mocked. Etc.
Very helpful. I recently started looking into unit testing again and I was looking for some simple breakdowns of how unit tests work.
Great to hear!
Unit Testing == Testing a single 'unit' of your code. That unit is as small as you define. Most of the time I've seen it down to the individual method or function level but it could be as small as a single statement if you really wanted to put the work into it.
This video came at such a good time!! Im building an API and want it to do some Unit testing, but i was kinda lost. Thanks Andy!
Awesome! What language are you writing it in?
@@AndySterkowitz im writing it in C Sharp. So it was a perfect example you gave.
Great video on Unit Testing, we briefly covered it in our boot camp. But simple, easy-to-understand examples!
I went into your channel and searched for the follow up videos but no luck!
Thanks for the great video and I hope you cover the rest in the future!
You explain stuff SO WELL! I just wish the example code was in JavaScript or PHP
He didnt teach us any syntax, so it doesnt matter. Thats because the syntax will change depending on the testing framework
I really like that you're providing coaching service, this is the first time I've seen anybody from RUclips offer that, very innovative of you :)
Hey Andy! Thank you for hitting the topic. It helps with a better understanding how unit testing works and from the looks of your github. I was able to kind of understand how to setup the testing but not fully.
Maturing as a developer is growing to love tests ❤
Memory Testing. To test individual class file with memory variable to make sure it can run by itself without fail. Validity of test data to make sure it can function within the code itself.
Wow when I watched this I thought how the hell would I do that for the thousands of lines of code I have? I guess what this is was a demonstration of just verifying that the correct output is produced by the input. Is that basically what "unit testing" is?
The key to unit testing is that your code is modularized. Testing thousands of lines of code is very difficult if not impossible. However if you had modularized your code to the point where you can test each module, now you can start to see how it can be possible.
Bro, awesome video! I wish you can add captions to non-native english speakers like me. Pretty useful!!!
I am taking a university degree they just threw material about testing .Guess what I have been stuck for days ,this video cleared a lot for me ..I kept on testing a function that connects to a database and ran into tonnes of errors
Great video, I would love to see deeper technical stuff from you. Thanks
I needed to have an idea about 2 subjects, Angular and Unite Testing. And you talked about Unit Testing IN your Angular video. WHAT ARE THE CHANCES?! Thank you.
Great Video! I do have a question: What is the difference between a Mock, a Stub and a Fake?
I would explain in this comment but this post actually does a terrific job of explaining it in detail: blog.pragmatists.com/test-doubles-fakes-mocks-and-stubs-1a7491dfa3da
Question, I've been researching employment in my area and I've come to find that unit testing knowledge is needed. The 6 major of Unit testing involve Mocha, Chai, JSHint/JSLint, Cypress, Jasmine and JSUnit. I'm leaning more towards Cypress because I code with Node, but also am learning Angular and React down the line. Out of the 6 I listed, which do you use and why?
Thanks for the beginner-friendly explanation
Trying to learn tests and this was amazing! Thank you! Great video!
enthusiasm shines from your face!
I love testing 😊
@@AndySterkowitz tell me this when cops stopped you when you was driving under influence after a party! just kidding I know developers all enjoy responsibly!
Better late than never ;)
I'm about to start my thesis and I picked this subject based on my boss's recommendation and found it to be very interesting. I was confused at first, nontheless, about how it worked, but this video was great for setting me on track. Thank you!
i love the background view, amazing
Finally a video that explains unit tests like I'm five.
you highly encourage me to do some research, how do you think i got to your video?
Great explanation. Short and sweet.
Great Description Andy!!
why can't you do more tutorials like this please? you probably won't ever answer me but please more videos like this.
In previous lives, I used Test Track Pro by Seapine Technology, that company was acquired by Perforce and the product is now called Helix TCM, but the product was very powerful at the time, are you using similar things in your automated testing?
Zeze Andjr yes
Still I can't undertand why unit testing is useful. Is it valid for codes writen by a single person or is it only necssary for a group of programmers?
Both. In an application it can help ensure that changes made to existing code doesn’t break. If you use a continuous integration server you can have all the tests in your project run each time you or someone else commits to a code base. This will help catch so many errors before they bubble up into production bugs.
@@AndySterkowitz, thanks for the answer. But can you make video with a real example or something? Maybe I don't see why this is important(although I know it's important, :-)) because the example is too simple.
@@AndySterkowitz Often is the case that changes don't break existing code but the unit test code.
Solid quick video. Thanks!
Yep. Ty
Thanks for the video! When you said 'do some research on your own', could you provide some good resource?
Unit testing has very limited usefulness for most web apps. 95% of the code that you write either interacts with the database or deals with the UI. And you can't unit test those things.
Thanks for this info!
i love your apartment, makes me miss chi
So unit tests are written when we know the code is working and we don't want it to be changed in future. Am I correct?
How can you know if your test is complete and correct? Can you make a test for your test?
could you please make a video for the xUnit over very simple programming that I can understand. I would really appreciate it.
Would the units you are typically testing be more complex than what is shown here? The test itself is more complicated than the unit it is testing in the example.
Definitely. This is meant to be a super simple example. Real life modules will typically have more logic that needs to be tested through each individual test.
Note to any Developers: If your company is NOT implementing any tests in the codebase, please do yourself a favour and QUIT, you deserve so much than said company AND/OR suggest they implement some testing framework, if that fails refer to previous step.
FYI, I have never been in a company that does NOT use some sort of testing framework whether it be Karma, Cypress, python unittest, Selenium, JEST, etc.
Terrible advice. Plenty of legacy systems don't have test suites and implementing them would take months which would be hard to justify to upper management. Plus as long as the money is good who cares?
Yo man, thanks so much for the explanation
I recently have had to use unit testing in a new role. Prior to that I had never used it and everything I programmed worked just fine. My personal opinion is that it's a huge waste of time. You want to program something, you program and run it. It crashes, you fix the code until it doesn't crach anymore. End of story. The more I stay in this software engineering role, the more I suspect this industry has invented a lot of additional stuff to delay the delivery of a product and waste the client's time.
Apparently the purpose of unit testing is to ensure quality standards. Quality to me means the program works and does what the client asked, and does not crash when used. That can be achieved in a more straight forward way and faster without implementing unit testing. But hey, I get paid to do what I love: code. If that means wasting the client's time, let's chuck that up to a business decision.
Can you add subtitles? It will be perfect!!
This was great! Thank you!
Bro, really nice video. Cheers from Brazil.
I always remember when he got his first job.
I was just like " he made it " and here we go I taught myself as well and been working for 5 months
thanks
Great vid, thanks! Can I ask - do you have an opinion on whether it is best to be using proper IDEs if you are doing this depth of work/testing?
if i applied this stuff to the android app i've been making for work i feel like i would have to write about 300,000 tests... and the app isn't that complicated. how do you know which units to test or not?
Awesome video!!
Thanks a Million for the Video. Can a self taught, code bootcamp grad be a Freelancer?
So how do you know what to test? I guess if you have a piece of logic that accepts data coming from different directions? My biggest issue rn is writing code to handle when data is not there.
I would like to know response from the people who read this comment ,so If you have some time to spare, please answer my questions.
1) Have you ever been asked by your supervisor to skip the unit testing code in order to save time and push the code to production ?
2)Does your codebase contain broken tests from the past which was caused by another developer who did not bother to fix it before committing his changes to repository ?
@Alexandria Amoretti Thanks for the reply. just out of curiosity, what technologies do you work on?
Highly informative
Can you do more videos like this please
clear, thanks.
the free session coaching link doesn't work
Thank you for the video.
I have one question, what if I have no mutch time to test my code?
Here we are building apps in two three weeks, and I have no time to make tests. Can you suggest me something?
Maybe first discuss the layout and the basics of your idea like the basic functions, what type each function/method is going to return + basic components of your app before starting to code.
After that, assign few members of your team to use this info to write the testing code even before writing the app code, while the other members write the app code. This way you will have two parties in your team runnning at the same time, one writing your app, and the other writing the test code.
I am a CS student and this is just my suggestion. Please do further research. There might be easier ways since this is just an idea that i came up just now.
@@isMeStranger Thanks bro. My comment is 2y old so far and I've grown a lot professionally. What you said makes a lot of sense.
My current approach is to write unit tests at least for the most important features when I don't have too much time
@@pedromassango Hello, thanks for your reply and for providing your current approach, it might be userful experience to know how people are working as programmers/developers as im graduating soon. Its good to see that you are much better at what you do now. Goodluck.
Thanks for the explain but i still dont get it. If i create a Tesla and within its constructor it uses the const char ptr "Tesla" to name it. Why should i test if its realy named "Tesla" ? I know that this is an easy example to understand but i dont get it. Its maybe the better way instead of put breaks or printf the Variables?
Shouldnt the object result be instantiated by the CarCreationService class method and not the _teslaCreationService class method?
7:52 is usually during the second half of the day ;)
What books do you suggest to get muscles in Unit testing?
why caption is unavailable? 😭
Why should I unit testing when I can debug? I really wanna know the reason why debugging isn't enough
Instead of testing the app manually (running the app and putting it through different test cases) you can write automated tests that do the work for you. This is the simplest way I can explain it.
Great video!!!!
thank you
What do you think about Head First Python, is it a good book to start learning Python?
The headfirst books are a bit outdated tbh, i would look elsewhere
thanks dude!
Are we testing Te-Z-la or Te-S-la?
I was just telling some student a about this they didn’t teach them in school
Hi Sir, can I become like you software developer in 3 years?
How and when are all these tests run?
thanks
That weird moment when your expected output is 'tesla'
And actual output is 'system crashed'
thanks!
Excllence. Never did this, and feel pretty stupid now ha
I think the title of this video is in fact “Unit Testing for “BEGINNERS.”
I still don't really understand why wouldn't you just print the value and compare it in your brain?
Because you can’t automate that 😊
@@AndySterkowitz It just seems like a big waste of time writing the tests if you're just comparing variables. It does make sense though if you're working in a team and you have tests run whenever someone commits, that can be very useful but then you would have to write new tests for every single new feature you add, right? I don't want this to sound like I'm criticising it, I just don't really understand....
Unit test is useless. Ideally the unit test code should cover all possible scenarios and thus eliminate bugs. But most unit test code I've seen only uses one or two set of data. So passing these tests only means that the code passed the most basic check. Also there's the tedious job of fixing unit test code once the original methods are changed. This is particularly true in Salesforce development where unit tests have to be verified in deployment.
TeSla! Where did you get TeZZla from?😂
I watched the cloud fly.
Awsome mate I'm here in 2021 I'm really committed in learning about how to host and code my own bot and server I have been trying to understand the language for months on end non stop 😴 I have been using the python progam to help me am I doing the right things
You have a really nice view from your office.
The sound quality is poor
Then you gotta test your tests
"Tezla"
I've been a dev for 5 years soon and I still don't see why people get so hyped on unit tests.
First of it shouldn't even be called test. It should be called business logic validation, because that's what the hell we are doing.
Second. Why do these "tests" even exist? It's only there to validate the business logic and if you know the business logic and expected output then why would you need to test for it.
It's expensive to write and maintain and it don't test user flows. It should be used in some cases but not all.
too simple examples.. how to you test methods with no return?
i hate unit testing. i never do it.
TDD is a thing but it requires a need for quality and it requires trust from the management.
I can see it for zero interference once deployed projects like Subsea Wellheads but anything other than that it will probably be too expensive.
Quality that can't be patched it very rare and that reduces TDDs value point.
It works but it might just be a bit expensive.
The world now is used to failing commodities. We are in the era of Planned obsceneness. Stuff won't last by design.
Building something of quality is counter productive in a capitalist society.
That's just depressing.
Luv and Peace.