Skip to content

Add standard JUnit tests for Task model and update pom.xml for new#61

Open
vogella wants to merge 1 commit intomainfrom
junit-standard-example
Open

Add standard JUnit tests for Task model and update pom.xml for new#61
vogella wants to merge 1 commit intomainfrom
junit-standard-example

Conversation

@vogella
Copy link
Copy Markdown
Member

@vogella vogella commented Apr 15, 2026

module

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +44 to +50
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));
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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>
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

Suggested change
<version>1.0.0-SNAPSHOT</version>
<version>${project.version}</version>

Comment on lines +23 to +29
<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>
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Hardcoding dependency versions in submodules can lead to maintenance issues and version mismatches. Consider managing these versions in the parent POM's <properties> or <dependencyManagement> section.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant