Next lesson playing in 5 seconds
Cancel- Overview
- Transcript
1.2 Test-Driven Development in Angular
In this video, I'll try to demystify the term Test-Driven Development and I'll look at a few alternative definitions.
Testing in Angular is not the same as testing a normal JavaScript application. There are many frameworks (an important selection of which we will learn in later videos) that are built specifically to test Angular apps. In this video, we'll take a birds-eye view of those libraries to get a sense of the landscape of testing for Angular.
1.Introduction3 lessons, 07:24
Free Lesson 1.1Introduction01:12
Free Lesson 1.2Test-Driven Development in Angular04:14
1.3Before You Start01:58
2.Scaffolding a Testable Angular App5 lessons, 46:23
2.1Introducing the Ironclad Address Book04:57
2.2App Setup11:37
2.3Serving Mocha Tests10:32
2.4Running Karma Tests11:33
2.5Implementing a Simple Back End With Express07:44
3.Testing Angular Applications5 lessons, 51:44
3.1Testing Services With Inject and Module12:45
3.2Verifying GET and POST Functionality With $httpBackend05:43
3.3Testing Angular Controllers12:27
3.4Testing Angular Filters10:19
3.5Testing Angular Directives10:30
4.Code Coverage With Istanbul3 lessons, 18:01
4.1What Is Istanbul?01:14
4.2Adding Istanbul to our Application09:40
4.3Generating and Serving a Code Coverage Report07:07
5.End-to-End Testing With Protractor4 lessons, 23:27
5.1Installing Protractor Dependencies03:55
5.2Configuring Selenium08:30
5.3Testing With Protractor05:06
5.4Automating Protractor05:56
6.Adding Finishing Touches4 lessons, 23:06
6.1Reviewing our App03:56
6.2Adding Contacts07:27
6.3Updating the Contact Display04:47
6.4Adding Styles06:56
7.Conclusion1 lesson, 04:05
7.1Conclusion04:05
1.2 Test-Driven Development in Angular
>> Hello ladies and gentlemen. In this video we're going to answer the question why test-driven development? You may have a lot of decisions to make when deciding the structure of your app. So, why should you decide to make it a test-driven development app? The first reason is that code which is backed up by tests is more reliable. The more tests you've written for a piece of code, the better you know its functionality, and the better you can define how it's going to work. We'll learn all about this as we write tests for our code. Another important detail is that when test is backed up by code, the responsibility of making sure it works doesn't lay on say the head developer or the intermediate developer, it's all sort of shared by the group, who as a whole maintains the quality of the test base. Another key advantage is it lets you focus, when writing the code, on writing the code itself. You don't need to write stuff into the code, like comments explaining what's its supposed to do, or its limitations. Because you can write tests that will describe this in your tests file. So, to many, what may be the most compelling reason to go with test-driven development is it lets projects meet needs that are very complex. You may work on a project and a list of needs may be 100 pages long with 1000 requirements. It's very difficult for one person to verify that all these requirements are met. However, automated testing shines for this and can really help you make sure your app is meeting many, many requirements. So, before you can answer the question, why is test-driven development right for you, you have to understand what test-driven development is. So, let's talk about that for a second. Basically when you write test-driven code, you're writing tests to make sure the code works. That's all there is to it. Now, once you've written these tests, you want your computer to run the tests automatically. This is called test automation and it's a big part of test-driven development. Finally, when you're writing test drive development you can't just write all your tests at the end together. You don't have to write them exactly before or at the same time. You can even write them two or three minutes after, but you have to write the tests basically at the same time. They should come in in the same call request. And finally, once you have written all those amazing tests, as a test-driven developer you'll use tools like, say, Istanbul to measure how much of your code you actually covered. Did you test very much of it? Or is half of your repository completely untested? So, how does this all fit in with Angular? As we'll see throughout this course, Angular was designed with a heavy emphasis on testing from day one. There are numerous hooks and features in Angular that allow us to test our code more efficiently and quickly. So, by choosing Angular you've made a good choice, we're at the very beginning, for a test-driven app. Additionally, we have a special tool called Karma which exists for running unit tests of many kinds, but almost especially for running unit tests with Angular. And we'll learn all about this. And finally we'll learn about Protractor, which is a tool for running very special tests, which tests your entire app from beginning to end. Protractor really lets you run tests that test stuff that is not simple, and by writing good end-to-end tests with Protractor you can really take your development to the next level. So, this is why you should do test-driven development, and I hope you'll enjoy the rest of the course.