Skip to content
Snippets Groups Projects
Commit 035b2a6d authored by Florian Schröder's avatar Florian Schröder
Browse files

Implement coverage measurement for tests

The pytest command in .gitlab-ci.yml has been updated to include code coverage measurements. The "coverage" Python package was added in setup.py under test requirements. Also, small updates were made in tests to reflect changes in the module imports and object comparisons.
parent 8c116f1f
No related branches found
No related tags found
1 merge request!31Resolve "More test coverage"
Pipeline #47462 failed
...@@ -5,7 +5,7 @@ pytest: ...@@ -5,7 +5,7 @@ pytest:
- apt-get install -y python3-dev python3-pip graphviz graphviz-dev - apt-get install -y python3-dev python3-pip graphviz graphviz-dev
- pip install pytest - pip install pytest
- pip install . - pip install .
- pytest --junitxml=report.xml - coverage run -m pytest --junitxml=report.xml
artifacts: artifacts:
when: always when: always
reports: reports:
......
...@@ -32,6 +32,7 @@ requirements = [ ...@@ -32,6 +32,7 @@ requirements = [
test_requirements = [ test_requirements = [
"pytest>=3", "pytest>=3",
"coverage>=7.4.3",
] ]
setup( setup(
......
import pytest import pytest
from overcooked_simulator.game_items import ItemInfo, CookingEquipment, Item, ItemType from cooperative_cuisine.game_items import ItemInfo, CookingEquipment, Item, ItemType
def test_can_combine_single_other_item(): def test_can_combine_single_other_item():
...@@ -61,12 +61,16 @@ def test_progress(): ...@@ -61,12 +61,16 @@ def test_progress():
cooking_equipment = CookingEquipment( cooking_equipment = CookingEquipment(
transitions={}, name="Pot", item_info=item_info transitions={}, name="Pot", item_info=item_info
) )
cooking_equipment.active_transition = {"seconds": 5.0, "result": "TestResult"} result = Item(name="TestResult", item_info=None)
cooking_equipment.active_transition = {
"seconds": 5.0,
"result": result,
}
from datetime import datetime, timedelta from datetime import datetime, timedelta
cooking_equipment.progress(passed_time=timedelta(seconds=5.0), now=datetime.now()) cooking_equipment.progress(passed_time=timedelta(seconds=5.0), now=datetime.now())
assert cooking_equipment.content_list == ["TestResult"] assert cooking_equipment.content_list == [result]
def test_reset_content(): def test_reset_content():
......
import pytest import pytest
from overcooked_simulator.game_items import ItemInfo, Item, ItemType from cooperative_cuisine.game_items import ItemInfo, Item, ItemType
@pytest.fixture @pytest.fixture
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment