-
Notifications
You must be signed in to change notification settings - Fork 23
feat: Adds Unit Tests Project & Employee Class implementations #482
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,35 @@ | ||
package com.codedifferently.lesson15; | ||
|
||
public class Employee { | ||
private int id; | ||
private String name; | ||
private String department; | ||
private double salary; | ||
|
||
public Employee(int id, String name, String department, double salary) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why did you delete this code? This is the code you're supposed to test. |
||
this.id = id; | ||
this.name = name; | ||
this.department = department; | ||
this.salary = salary; | ||
} | ||
|
||
// Getters and setters | ||
public int getId() { | ||
return id; | ||
} | ||
|
||
public void setId(int id) { | ||
this.id = id; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
import com.google.common.annotations.VisibleForTesting; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't need to use this. |
||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public String getDepartment() { | ||
return department; | ||
} | ||
|
||
public void setDepartment(String department) { | ||
this.department = department; | ||
} | ||
|
||
public double getSalary() { | ||
return salary; | ||
} | ||
|
||
public void setSalary(double salary) { | ||
this.salary = salary; | ||
public class Employee { | ||
private static final String Details = null; | ||
private int id; | ||
private String name; | ||
private String department; | ||
private double salary; | ||
|
||
public Employee(int id, String name, String department, double salary) { | ||
this.id = id; | ||
this.name = name; | ||
this.department = department; | ||
this.salary = salary; | ||
} | ||
|
||
public void testGetDetails() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test code belongs in a test file, not here. |
||
Employee employee = new Employee(id, "Will Smith", department, 101); | ||
String expected = "Employee Name: Will Smith, id: 101:"; | ||
String actual = employee.getDetails(); | ||
|
||
assertEquals(expected, actual); | ||
} | ||
|
||
private void assertEquals(String expected, String actual) { | ||
// TODO Auto-generated method stub | ||
throw new UnsupportedOperationException("Unimplemented method 'assertEquals'"); | ||
} | ||
|
||
public String getDetails() { | ||
return Details; | ||
} | ||
} |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto on formatting. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Formatting looks weird, you should run
./gradlew spotlessApply
.