Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
mb_app
tests
mb_tests
log.mbapp.txt
log.microbiome.txt
log.simulation.txt
Expand Down
14 changes: 13 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
MAIN_FILE = src/mbapp.cpp
TESTS_FILE = src/tests.cpp
CATCH2_TEST_FILE = test/test_microbiome.cpp
PROJECT_FILES = src/microorganism.cpp src/microbiome.cpp src/appConfig.cpp src/simulation.cpp src/result.cpp src/logger.cpp src/microorganismFactory.cpp
ENVLIBCPP_FILES = env-lib-cpp/src/entity.cpp env-lib-cpp/src/environment.cpp env-lib-cpp/src/grid.cpp env-lib-cpp/src/location.cpp

Expand All @@ -10,5 +11,16 @@ all: mbapp tests
mbapp: src/mbapp.cpp
g++ $(WARNING_FLAGS) $(MAIN_FILE) $(PROJECT_FILES) $(ENVLIBCPP_FILES) -o mb_app
Copy link

Copilot AI Sep 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Specify the C++ standard explicitly to ensure consistent builds across environments (Catch2 v2 requires C++11+). For example, add -std=c++17 to these compile commands, or define CXXFLAGS = -std=c++17 $(WARNING_FLAGS) and reuse it.

Copilot uses AI. Check for mistakes.

# Legacy tests (for backward compatibility)
tests: src/tests.cpp
g++ $(WARNING_FLAGS) $(PROJECT_FILES) $(ENVLIBCPP_FILES) $(TESTS_FILE) -o tests
g++ $(WARNING_FLAGS) $(PROJECT_FILES) $(ENVLIBCPP_FILES) $(TESTS_FILE) -o tests
Copy link

Copilot AI Sep 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Specify the C++ standard explicitly to ensure consistent builds across environments (Catch2 v2 requires C++11+). For example, add -std=c++17 to these compile commands, or define CXXFLAGS = -std=c++17 $(WARNING_FLAGS) and reuse it.

Copilot uses AI. Check for mistakes.

# Catch2 tests (new)
catch2_tests: test/test_microbiome.cpp
g++ $(WARNING_FLAGS) -I test $(PROJECT_FILES) $(ENVLIBCPP_FILES) $(CATCH2_TEST_FILE) -o mb_tests
Copy link

Copilot AI Sep 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Specify the C++ standard explicitly to ensure consistent builds across environments (Catch2 v2 requires C++11+). For example, add -std=c++17 to these compile commands, or define CXXFLAGS = -std=c++17 $(WARNING_FLAGS) and reuse it.

Copilot uses AI. Check for mistakes.

# Default test target points to catch2_tests
test: catch2_tests

clean:
rm -f mb_app tests mb_tests
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ Ticks elapsed: 16 of 120
```

## Testing
The project now uses **Catch2** as the primary testing framework, providing better test organization and reporting.

### How to run the tests in the dev container
1. Install Docker
2. Clone the repository
Expand All @@ -34,7 +36,19 @@ Ticks elapsed: 16 of 120
5. Click on the green button in the bottom left corner of the window.
6. Select "Reopen in Container".
7. Open a terminal in VSCode.
8. Run the `./run_tests.sh` script or build the tests with `make tests` and run them with `./mb_tests`.
8. Run the `./run_tests.sh` script or build the tests with `make catch2_tests` and run them with `./mb_tests`.

### Available Test Commands
- `make catch2_tests` - Build and use Catch2 framework tests (recommended)
- `make tests` - Build legacy assert-based tests (for backward compatibility)
- `make test` - Alias for `catch2_tests`
- `./run_tests.sh` - Run both Catch2 and legacy tests

### Catch2 Features
- Better test reporting and failure diagnostics
- Test filtering by tags: `./mb_tests [microorganism]`
- Verbose output: `./mb_tests --success`
- List all tests: `./mb_tests --list-tests`

## Running the application
### How to run the application with Docker-Compose
Expand Down
18 changes: 13 additions & 5 deletions run_tests.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
# remove old executable
rm ./tests
# Remove old executables
rm -f ./tests ./mb_tests

# compile
make tests
# Compile Catch2 tests (default)
Comment on lines +1 to +4
Copy link

Copilot AI Sep 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Add a shebang and strict mode to make the script fail fast and be more robust. Suggested header: #!/usr/bin/env bash followed by set -euo pipefail.

Copilot uses AI. Check for mistakes.
make catch2_tests

# Run Catch2 tests
./mb_tests

# run
echo ""
echo "Catch2 tests completed."

# Optionally run legacy tests for comparison
echo "Running legacy tests for comparison..."
make tests
./tests
Comment on lines +14 to 16
Copy link

Copilot AI Sep 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment says 'Optionally' but the script always runs legacy tests. Either update the comment or gate these lines behind a flag, e.g.: if [ "${RUN_LEGACY:-0}" = "1" ]; then ... fi.

Suggested change
echo "Running legacy tests for comparison..."
make tests
./tests
if [ "${RUN_LEGACY:-0}" = "1" ]; then
echo "Running legacy tests for comparison..."
make tests
./tests
fi

Copilot uses AI. Check for mistakes.
Loading