From the course: Complete Guide To Java Testing with JUnit 5 & Mockito
Unlock the full course today
Join today to access over 24,900 courses taught by industry experts.
Refactor tests to ensure maintainability
From the course: Complete Guide To Java Testing with JUnit 5 & Mockito
Refactor tests to ensure maintainability
- [Instructor] We've implemented two classes, task manager and task using test-driven development, where we've written the tests before we've written the code. We've completed the requirements for the project, but now let's review our code and see if there's anything we can improve. We'll start off with our task manager test. Here we create a new task manager with every single test. Let's use a before each annotation and create a task manager for the entire class. Before each test method, we'll run the setup where we set the task manager to be a new instance. This will replace the task manager used in each test. With this re-consolidation and re-naming, it makes it clear exactly what we're testing. Given most of our tests, use at least one task, we can also set up a task in our setup method. Let's replace the task references in the rest of our class with this task. In this case, the task description doesn't really matter because it's not used in any of the assertions. This means we…
Contents
-
-
-
-
-
Task manager project prompt1m 17s
-
(Locked)
Set up red phase for Add Task functionality in Test Class3m 3s
-
(Locked)
Implement Get ID in Task Class2m 14s
-
(Locked)
Implement Add Task and enter green phase1m 54s
-
(Locked)
Prevent tasks with duplicate IDs4m 48s
-
(Locked)
Implement Remove Task with Test Driven Development2m 45s
-
(Locked)
Implement task descriptions with Test Driven Development2m 56s
-
(Locked)
Implement Update Description with Test Driven Development2m 1s
-
(Locked)
Implement Retrieve Task with Test Driven Development2m
-
(Locked)
Refactor tests to ensure maintainability6m 44s
-
-
-
-
-
-
-