Skip to content

Solution for the "Java and JavaScript. Programming Procedures" challenge, focusing on unit testing with JUnit and JaCoCo.

Notifications You must be signed in to change notification settings

carlop13/java-and-js-unit-testing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Challenge: Java & JavaScript Programming Procedures

Java Maven JavaScript Node.js JUnit5 Jest

1. Project Overview

This repository contains the complete solution for the "Java and JavaScript. Programming Procedures" challenge. The project demonstrates professional software quality assurance practices by implementing robust unit testing suites and comprehensive documentation for both a Java backend module and a JavaScript utility module.

The project is structured into three sprints, covering:

  • Sprint 1: Unit testing a Java reservations module with JUnit 5.
  • Sprint 2: Unit testing a JavaScript city graph module with Jest.
  • Sprint 3: Finalizing all project documentation, including in-code comments and architectural diagrams.

2. 🚀 Getting Started

Follow these instructions to set up the project, run all tests, and view the coverage reports.

Prerequisites

  • JDK 17 or higher
  • Apache Maven
  • Node.js and npm (v18 or higher recommended)

Installation

  1. Clone the Repository

    git clone https://github.com/carlop13/java-unit-testing-challenge.git
    cd java-unit-testing-challenge

    (Note: Ensure this URL matches your repository's URL).

  2. Install JavaScript Dependencies The JavaScript module has its own dependencies managed by npm.

    cd sprint-2-javascript
    npm install
    cd .. 

3. 🧪 Test Suite Description and Execution

This project includes two separate test suites designed to validate the correctness and robustness of each module.

3.1. Java Module (JUnit)

This test suite, located in src/test/java, validates the ReservationService class. It covers all core functionalities (create, edit, cancel) and includes tests for negative scenarios and exception handling.

  • How to Execute: From the project's root directory, run the following Maven command:
    mvn clean verify
  • Expected Result (Snippet): The command will compile, run tests, and generate a coverage report, ending with a BUILD SUCCESS message.
    [INFO] Tests run: 9, Failures: 0, Errors: 0, Skipped: 0
    ...
    [INFO] BUILD SUCCESS
    
    The full JaCoCo coverage report is generated at target/site/jacoco/index.html.

3.2. JavaScript Module (Jest)

This test suite, located in sprint-2-javascript/, validates the getNearbyCities function. It focuses on correct data transformation, edge cases, and handling of invalid inputs.

  • How to Execute:

    1. Navigate to the Sprint 2 directory: cd sprint-2-javascript
    2. Run the tests and generate the coverage report: npm run test:coverage
  • Expected Result (Snippet): Jest will display a passing status and a coverage summary in the terminal.

     PASS  ./graph.test.js
    ...
    Test Suites: 1 passed, 1 total
    Tests:       5 passed, 5 total
    

    The full HTML coverage report is generated at sprint-2-javascript/coverage/lcov-report/index.html.


4. 📄 Project Documentation

As part of Sprint 3, comprehensive documentation was created to ensure the project is maintainable and easy to understand.

4.1. Code Documentation

  • Java Module: All public classes and methods in the com.bookingmx.reservations package are documented using Javadoc comments. This explains the purpose, parameters, and return values of each component.
  • JavaScript Module: The getNearbyCities function in graph.js is documented using JSDoc comments, clarifying its functionality, parameters, and expected behavior.

4.2. System Architecture Diagrams

Diagrams illustrating the system architecture and development workflow have been created and are available in the following file:

This PDF includes a class diagram for the Java module and a flowchart of the testing and development process.

4.3. Technical Learnings and Peer Review

In response to project feedback, a self-review process was conducted during Sprint 2. The findings and strategies for improving test robustness are documented in:


5. 🏆 Sprint Achievements Summary

Sprint Focus Key Achievement Final Coverage
1 Java Unit Testing (JUnit) Implemented a TDD cycle to find and fix a bug. 93%
2 JavaScript Unit Testing (Jest) Focused on deep exception and edge case testing. 100%
3 Documentation & Finalization Created comprehensive project and code documentation. N/A

About

Solution for the "Java and JavaScript. Programming Procedures" challenge, focusing on unit testing with JUnit and JaCoCo.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published