Skip to content

Commit

Permalink
(#80) Add Testing Guidelines to CONTRIBUTING and Documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
SevgiAkten committed Nov 28, 2024
1 parent 358074a commit 390ca98
Show file tree
Hide file tree
Showing 3 changed files with 131 additions and 17 deletions.
33 changes: 32 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,38 @@ Please ensure your code follows the project's coding standards. Use PEP 8 as a g

### Testing

Ensure that your code changes do not break existing tests and write new tests for new functionality. Run all tests to verify.
Before submitting a pull request, ensure that your changes pass all the tests and do not introduce any regressions. Here's how to test your changes:

1. **Set up your environment**:
- Install all necessary dependencies from `requirements.txt`:
```bash
pip install -r requirements.txt
```
- Install any additional developer dependencies:
```bash
pip install pytest pytest-cov
```

2. **Run the tests**:
- Execute the test suite using `pytest`:
```bash
pytest
```
- Verify that all tests pass without errors.

3. **Check code coverage**:
- Run tests with coverage reporting:
```bash
pytest --cov=pycellga
```
- Ensure that your changes do not significantly reduce the code coverage. A minimum of 90% coverage is recommended.

4. **Add new tests (if applicable)**:
- If your changes introduce new features or modify existing functionality, write additional test cases to cover these changes.
- Place your tests in the appropriate subdirectory within the `tests` folder, following the naming convention `test_<feature_name>.py`.

5. **Review testing guidelines**:
- Ensure your tests follow the existing style and structure used in the project. Use descriptive function names and provide comments where necessary to clarify the test's purpose.
### Documentation
Expand Down
48 changes: 48 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,54 @@ We have provided a basic example above. If you're interested in exploring more e

Contributions are welcome! Please read the contributing guidelines first.

## Testing

To ensure that `pycellga` works as expected, we have provided a comprehensive suite of tests. Follow these steps to run the tests locally:

1. **Install dependencies**: Make sure you have installed all the necessary dependencies from `requirements.txt`. You can install them using the following command:

```bash
pip install -r requirements.txt
```

2. **Run tests**: Navigate to the root directory of the project and run the test suite using `pytest`.

```bash
pytest
```

This will automatically discover and execute all the test cases.

3. **Check code coverage** (Optional): You can check the test coverage of the package using `pytest-cov`. First, ensure you have installed `pytest-cov`:

```bash
pip install pytest-cov
```

Then, run the tests with coverage reporting:

```bash
pytest --cov=pycellga
```

A summary of code coverage will be displayed in the terminal.

4. **Generate coverage reports**: If you want a detailed HTML report of the code coverage, run:

```bash
pytest --cov=pycellga --cov-report=html
```

Open the `htmlcov/index.html` file in a web browser to view the detailed coverage report.

5. **Add new tests (if applicable)**:
- If your changes introduce new features or modify existing functionality, write additional test cases to cover these changes.
- Place your tests in the appropriate subdirectory within the `tests` folder, following the naming convention `test_<feature_name>.py`.

6. **Review testing guidelines**:
- Ensure your tests follow the existing style and structure used in the project. Use descriptive function names and provide comments where necessary to clarify the test's purpose.
## License
This project is licensed under the MIT License - see the LICENSE file for details.
Expand Down
67 changes: 51 additions & 16 deletions docs/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ Contributing

We’re thrilled that you’re considering contributing to `pycellga`! Community contributions drive innovation and help us improve the software. Whether it’s reporting bugs, suggesting enhancements, or submitting pull requests, your support is invaluable.


Ways to Contribute
------------------

Expand Down Expand Up @@ -64,19 +63,19 @@ When you’re ready to submit your changes, follow these guidelines to ensure a
1. **Write Clear Commit Messages**: Each commit message should be clear and descriptive.
2. **Run Tests**: Verify that all tests pass. Tests can be run from the `tests` folder or main directory:

- From the `tests` folder:
- From the `tests` folder:

.. code-block:: bash
.. code-block:: bash
cd tests
pytest * # or
pytest -v
cd tests
pytest * # or
pytest -v
- From the main project directory:
- From the main project directory:

.. code-block:: bash
.. code-block:: bash
pytest -v
pytest -v
3. **Submit a Pull Request**: Push your branch to GitHub, navigate to the main repository, and open a pull request.

Expand All @@ -98,19 +97,55 @@ Before submitting a pull request, ensure that all tests pass. Tests can be run i

1. **From the `tests` folder**:

.. code-block:: bash
.. code-block:: bash
cd tests
pytest * # or
pytest -v
cd tests
pytest * # or
pytest -v
2. **From the main project directory**:

.. code-block:: bash
.. code-block:: bash
pytest -v
Testing Guidelines
------------------

Here are additional details for testing your contributions:

1. **Set up your environment**:

- Install the dependencies listed in `requirements.txt`:

.. code-block:: bash
pip install -r requirements.txt
- Install testing dependencies like `pytest`:

.. code-block:: bash
pip install pytest pytest-cov
2. **Run coverage checks**:

- To ensure your changes are covered by tests, run:

.. code-block:: bash
pytest --cov=pycellga
3. **Write new tests**:

- If your contribution involves new functionality, write test cases to validate its behavior.
- Place test files in the `tests` folder, following the naming convention `test_<feature_name>.py`.

pytest -v
4. **Review existing tests**:

If you add new functionality, consider adding tests to cover your changes.
- Familiarize yourself with the project's test structure by reviewing existing tests in the `tests` folder.
- Ensure your tests align with the same style and structure.

By following these testing guidelines, you help maintain the quality and reliability of `pycellga`.

Thank you for considering a contribution to `pycellga`. We’re excited to see what you’ll bring to the project!

0 comments on commit 390ca98

Please sign in to comment.