DEV Community

Cover image for The Second Week of Project 1: Unit Testing
CyberFriend
CyberFriend

Posted on

The Second Week of Project 1: Unit Testing

As the second week of Project 1 rolled in, our task to build the unit tests we had each chosen began. To recap, me and seven other classmates were grouped into a team to practice unit tests, with a focus on working via GitHub. This project was designed to throw us into the reality of software engineering. Working in teams isn’t always as smooth as it should be, and remote work especially demands flawless communication, which not everyone is used to.

For this project, I took on the role of team lead. Honestly, I did everything I could to ensure our final tests were 100% successful (and maybe even went beyond my assigned role to make that happen!).

Below, you can see the methods I selected for my testing:

Image description

In Part B of the project, I worked with IntelliJ using the Gradle tool. Our team agreed to maintain a consistent commenting style across all tests so our code would look cohesive as one unified project. For example, here’s part of my test for HSetTest:
`@DisplayName("Yurii - HSetTest")
class HSetTest {
HSet hSet;

@BeforeEach
@DisplayName("Setting up the test environment")
void setUp() { 
    hSet = new HSet<>(); 
}

@AfterEach
@DisplayName("Tearing down the test environment")
void tearDown() { 
    hSet.clear(); 
}

@Test
@DisplayName("HSet size should return 0 after creation")
void size() {
    assertEquals(0, hSet.size(), "The size of a newly created HSet should be 0");
}
Enter fullscreen mode Exit fullscreen mode

}

Since I had never done Unit Testing before, this project was not exactly a walk in the park. However, with some effort, I managed to complete all my tests and even helped other team members who ran into issues. One of the key lessons from this project was learning to work with GitHub’s pull requests. The whole process of reviewing and merging files was new to me but quite interesting to navigate as part of a team.

I believe one of the most important aspects of this project was setting rules for the main branch. Since many of us were new to working with pull requests, some initial mistakes could have seriously harmed the entire project. Luckily, we reviewed each pull request carefully, which saved us from potential disaster.

After missing our internal deadline (we are still on the project time tho), we finally managed to run all the tests successfully and achieved a 100% pass rate.

Image description

Top comments (0)