-
Notifications
You must be signed in to change notification settings - Fork 25
feat: adds Kimberlee's Lesson 15 TDD: Unit test building #500
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
61e99da
feat:added test files
haldanek 915b285
fix: fixed lesson15test file
haldanek 3b4a5e5
chore: added second test
haldanek 91c8815
chore: edit test 2
haldanek bfc1c22
chore: adds test 3
haldanek 3e0ee14
fix: fixed test files
haldanek 5bda902
fix: file edit
haldanek 7847f94
chore: updated employeemanagertest
haldanek b56345f
chore: edit files
haldanek 08346a3
Merge branch 'code-differently:main' into Lesson_15
haldanek 328c058
chore: tried to fix tests/ removeEmployee and
haldanek 36e2963
Merge remote-tracking branch 'refs/remotes/origin/Lesson_15' into Les…
haldanek f1d9734
feat: adds Employee.java test and getDetails Method
haldanek File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
lesson_15/tdd/tdd_app/src/test/java/com/codedifferently/lesson15/EmployeeManagerTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package com.codedifferently.lesson15; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.assertj.core.api.Assertions.assertThatThrownBy; | ||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
class EmployeeManagerTest { | ||
|
||
private EmployeeManager employeeManager; | ||
private Employee employee; | ||
|
||
@BeforeEach | ||
void setUp() { | ||
employeeManager = new EmployeeManager(); | ||
employee = new Employee(1, "Edgar Allen Poe", "Publications", 0.0); | ||
employeeManager.addEmployee(employee); | ||
} | ||
|
||
@Test | ||
void testAddEmployee() { | ||
// Arrange | ||
Employee newEmployee = new Employee(2, "Sheet Ghost", "Administration", 0.0); | ||
// Act | ||
employeeManager.addEmployee(newEmployee); | ||
// Assert | ||
assertThat(employeeManager.getEmployee(2)).isEqualTo(newEmployee); | ||
} | ||
|
||
@Test | ||
void testGetEmployee() { | ||
// Act | ||
Employee actualEmployee = employeeManager.getEmployee(1); | ||
// Assert | ||
assertThat(actualEmployee).isEqualTo(employee); | ||
} | ||
|
||
@Test | ||
void testUpdateEmployee() { | ||
// Arrange | ||
Employee updatedEmployee = new Employee(1, "Frankenstein", "Development", 0.0); | ||
// Act | ||
employeeManager.updateEmployee(updatedEmployee); | ||
Employee actualEmployee = employeeManager.getEmployee(1); | ||
// Assert | ||
assertThat(actualEmployee).isEqualTo(updatedEmployee); | ||
} | ||
|
||
@Test | ||
void testRemoveEmployee() { | ||
// Act | ||
employeeManager.removeEmployee(1); | ||
Employee removedEmployee = employeeManager.getEmployee(1); | ||
// Assert | ||
assertEquals(0, employeeManager.getEmployeeCount(), "Employee count should be 0"); | ||
assertNull(removedEmployee, "Employee should be removed from directory."); | ||
} | ||
|
||
@Test | ||
void testAssertEmployeeInCollection() { | ||
// Arrange & Act & Assert | ||
assertThatThrownBy(() -> employeeManager.getEmployee(52)) | ||
.isInstanceOf(IllegalArgumentException.class) | ||
.hasMessage("Employee does not exist in collection with Id 1"); | ||
} | ||
|
||
@Test | ||
void testGetEmployeeCount() { | ||
// Arrange | ||
Employee addNew1 = new Employee(2, "Dracula", "Medical", 0.0); | ||
Employee addNew2 = new Employee(3, "Blade", "Security", 0.0); | ||
// Act | ||
employeeManager.addEmployee(addNew1); | ||
employeeManager.addEmployee(addNew2); | ||
// Assert | ||
assertEquals(3, employeeManager.getEmployeeCount()); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
lesson_15/tdd/tdd_app/src/test/java/com/codedifferently/lesson15/EmployeeTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.codedifferently.lesson15; | ||
|
||
import static org.assertj.core.api.Assertions.*; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
public class EmployeeTest { | ||
private Employee employee; | ||
|
||
@Test | ||
void testGetDetails() { | ||
// Arrange | ||
employee = new Employee(1, "Jet Li", "Specialist", 110.00); | ||
// Act | ||
Employee actualDetails = employee.getDetails(employee); | ||
// Assert | ||
assertThat(actualDetails).isEqualTo(employee); | ||
} | ||
} |
18 changes: 0 additions & 18 deletions
18
lesson_15/tdd/tdd_app/src/test/java/com/codedifferently/lesson15/Lesson15Test.java
haldanek marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1 @@ | ||
package com.codedifferently.lesson15; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
class Lesson15Test { | ||
|
||
@Test | ||
public void testLesson15() { | ||
assertThat(new Lesson15()).isNotNull(); | ||
} | ||
|
||
@Test | ||
public void testGetGreeting() { | ||
// Act | ||
Lesson15.main(null); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.