From the course: Complete Guide To Java Testing with JUnit 5 & Mockito
Unlock the full course today
Join today to access over 24,700 courses taught by industry experts.
Implement Retrieve Task with Test Driven Development
From the course: Complete Guide To Java Testing with JUnit 5 & Mockito
Implement Retrieve Task with Test Driven Development
- [Instructor] The last feature we'll add to this application is the ability to retrieve a task. In the Project Requirements we set a task is referenced by its ID, so let's create a test for this in our Task Manager. For the setup, we'll want to add a task to the Task Manager that we can retrieve. Let's create a new taskManager, a new task, and add it to our manager. To retrieve the task, we'll use its ID. This method should return a task. Then in our test, we'll verify it's the same task we added. We could also add assertions that verify the task ID and description if the exact object doesn't need to be equal. Given we're storing the exact object, this assertion covers all of those cases with this single line of code. Now, let's create the method signature for Git. That'll make the test compile. This will return a task and will pass in an ID. By default, it will return null. Let's run our test. Our test fails because we need to implement the get method. For our implementation, we'll…
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
-
-
-
-
-
-
-