-
Notifications
You must be signed in to change notification settings - Fork 0
Transition testing framework from custom assert-based tests to Catch2 #22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
187c0ee
5712b36
ace1bbc
44b8ce3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 | ||
|
|
||
| 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 | ||
|
|
||
|
|
@@ -10,5 +11,16 @@ all: mbapp tests | |
| mbapp: src/mbapp.cpp | ||
| g++ $(WARNING_FLAGS) $(MAIN_FILE) $(PROJECT_FILES) $(ENVLIBCPP_FILES) -o mb_app | ||
|
|
||
| # 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 | ||
|
||
|
|
||
| # Catch2 tests (new) | ||
| catch2_tests: test/test_microbiome.cpp | ||
| g++ $(WARNING_FLAGS) -I test $(PROJECT_FILES) $(ENVLIBCPP_FILES) $(CATCH2_TEST_FILE) -o mb_tests | ||
|
||
|
|
||
| # Default test target points to catch2_tests | ||
| test: catch2_tests | ||
|
|
||
| clean: | ||
| rm -f mb_app tests mb_tests | ||
| 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
|
||||||||||||||||||
| 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
|
||||||||||||||||||
| 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 |
There was a problem hiding this comment.
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.