Skip to content

kyanny/refactored-octo-waddle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FizzBuzz Project

This project implements a FizzBuzz function and includes unit tests for it. It also provides a CI/CD configuration to run the unit tests and generate a coverage report.

Project Structure

The project has the following files and directories:

  • fizzbuzz/__init__.py: An empty file that marks the fizzbuzz directory as a Python package.

  • fizzbuzz/fizzbuzz.py: Contains the implementation of the fizzbuzz function. This function takes an integer as input and returns a string based on the FizzBuzz rules.

  • tests/__init__.py: An empty file that marks the tests directory as a Python package.

  • tests/test_fizzbuzz.py: Contains the unit tests for the fizzbuzz function. It uses a testing framework like unittest or pytest to define test cases and assertions.

  • .github/workflows/ci.yml: The configuration file for the CI/CD workflow. It specifies the steps to run the unit tests and generate a coverage report. It uses a CI/CD platform like GitHub Actions to automate the process.

  • .coveragerc: The configuration file for the coverage report. It specifies the settings for the coverage analysis, such as which files to include or exclude from the report.

  • requirements.txt: Lists the dependencies required for the project. It includes the packages needed for testing and generating the coverage report.

FizzBuzz Function

The fizzbuzz function is implemented in the fizzbuzz/fizzbuzz.py file. It takes an integer as input and returns a string based on the following rules:

  • If the number is divisible by 3, it returns "Fizz".
  • If the number is divisible by 5, it returns "Buzz".
  • If the number is divisible by both 3 and 5, it returns "FizzBuzz".
  • Otherwise, it returns the input number as a string.

Unit Tests

The unit tests for the fizzbuzz function are implemented in the tests/test_fizzbuzz.py file. They use the unittest framework to define test cases and assertions. The tests cover different scenarios to ensure the correct behavior of the fizzbuzz function.

CI/CD Configuration

The CI/CD configuration is defined in the .github/workflows/ci.yml file. It specifies the steps to run the unit tests and generate a coverage report using a CI/CD platform like GitHub Actions. The configuration ensures that the tests are executed automatically whenever changes are pushed to the repository.

Coverage Report

The coverage report is generated based on the settings specified in the .coveragerc file. It includes information about the code coverage of the project, indicating which parts of the code are covered by the unit tests.

Running the Unit Tests

To run the unit tests locally, follow these steps:

  1. Clone the repository to your local machine.
  2. Install the project dependencies by running pip install -r requirements.txt.
  3. Navigate to the project root directory.
  4. Run the command python -m unittest discover tests to execute the unit tests.

Generating the Coverage Report

To generate the coverage report locally, follow these steps:

  1. Ensure that the project dependencies are installed (see previous section).
  2. Navigate to the project root directory.
  3. Run the command coverage run -m unittest discover tests to execute the unit tests and collect coverage data.
  4. Run the command coverage report to display the coverage report in the console.
  5. Optionally, run the command coverage html to generate an HTML report in the htmlcov directory.

That's it! You now have a FizzBuzz project with unit tests and a CI/CD configuration to run the tests and generate a coverage report. Happy coding!

About

No description, website, or topics provided.

Resources

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages