Add standard JUnit tests for Task model and update pom.xml for new#61
Add standard JUnit tests for Task model and update pom.xml for new#61
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a new test module, com.vogella.tasks.model.tests, containing unit tests for the Task class, and updates the root project to include this module while bumping the Tycho version to 5.0.2. Feedback suggests enhancing the TaskTest to verify all fields during object copying and using more idiomatic assertions. Additionally, it is recommended to use ${project.version} for internal dependencies and manage external dependency versions in the parent POM to improve maintainability.
| void copyProducesEquivalentTask() { | ||
| Task original = new Task(7, "Write tests", "Add unit tests", false, LocalDate.of(2026, 1, 1)); | ||
| Task copy = original.copy(); | ||
| assertEquals(original.getId(), copy.getId()); | ||
| assertEquals(original.getSummary(), copy.getSummary()); | ||
| assertTrue(original.equals(copy)); | ||
| } |
There was a problem hiding this comment.
The copyProducesEquivalentTask test should verify that all fields of the Task object are correctly copied, including description, done, and dueDate. Also, using assertEquals(original, copy) is more idiomatic and provides better failure messages than assertTrue(original.equals(copy)).
void copyProducesEquivalentTask() {
LocalDate dueDate = LocalDate.of(2026, 1, 1);
Task original = new Task(7, "Write tests", "Add unit tests", false, dueDate);
Task copy = original.copy();
assertEquals(original.getId(), copy.getId());
assertEquals(original.getSummary(), copy.getSummary());
assertEquals(original.getDescription(), copy.getDescription());
assertEquals(original.isDone(), copy.isDone());
assertEquals(original.getDueDate(), copy.getDueDate());
assertEquals(original, copy);
}| <dependency> | ||
| <groupId>com.vogella.tycho</groupId> | ||
| <artifactId>com.vogella.tasks.model</artifactId> | ||
| <version>1.0.0-SNAPSHOT</version> |
There was a problem hiding this comment.
It is better to use ${project.version} for internal dependencies within the same reactor. This ensures that the test module always uses the version of the model it is being built with, and avoids the need for manual updates.
| <version>1.0.0-SNAPSHOT</version> | |
| <version>${project.version}</version> |
| <version>5.14.1</version> | ||
| <scope>test</scope> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.junit.platform</groupId> | ||
| <artifactId>junit-platform-launcher</artifactId> | ||
| <version>1.14.1</version> |
module