Hello, I am a beginner so I probably just misunderstood how to use this package, however it seems that my installation has trouble collecting tests from C++ files. Here's my situation:
- I have both pytest and pytest-cpp installed (both through pip).
- I have a folder containing:
'generator_demo_test.py' that has two test functions, each with its own assert statement
'generator_demo_test.cpp' that #includes gtest.h and has two TEST() functions (but no main() function, if that makes a difference)
I compiled the cpp file with gtest and now have demo_test.exe in the folder with the .py and .cpp files. Then I open a terminal in that folder and type py.test --collect-only and I get the following output:
=============test session starts =============
platform win32 -- Python 3.7.7, pytest-5.4.1, py-1.8.1, pluggy-0.13.1
rootdir: C:\Users\myuser\Documents\Code\10_Local\demo
plugins: allure-pytest-2.8.10, cpp-1.2.0, TyphoonTest-1.11.1
collected 2 items
<Module generator_demo_test.py>
<Function test_vout>
<Function test_samples>
=============no tests ran in 0.14s ==========
So the c++ tests are ignored.
However, if I type py.test --collect-only generator_demo_test.exe, then the output is:
================================================= test session starts =================================================
platform win32 -- Python 3.7.7, pytest-5.4.1, py-1.8.1, pluggy-0.13.1
rootdir: C:\Users\myuser\Documents\Code\10_Local\demo
plugins: allure-pytest-2.8.10, cpp-1.2.0, TyphoonTest-1.11.1
collected 2 items
<CppFile oldgenerator_demo_test.exe>
<CppItem Addition_TEST_SUITE.AdderTest_SIMPLE>
<CppItem Addition_TEST_SUITE.AdderTest_COMPLEX>
================================================== warnings summary ===================================================
c:\users\myuser\appdata\local\programs\python\python37\lib\site-packages\pytest_cpp\plugin.py:41
c:\users\myuser\appdata\local\programs\python\python37\lib\site-packages\pytest_cpp\plugin.py:41: PytestDeprecationWarning: direct construction of CppFile has been deprecated, please use CppFile.from_parent
return CppFile(path, parent, facade_class(), test_args)
c:\users\myuser\appdata\local\programs\python\python37\lib\site-packages\pytest_cpp\plugin.py:67
c:\users\myuser\appdata\local\programs\python\python37\lib\site-packages\pytest_cpp\plugin.py:67
c:\users\myuser\appdata\local\programs\python\python37\lib\site-packages\pytest_cpp\plugin.py:67: PytestDeprecationWarning: direct construction of CppItem has been deprecated, please use CppItem.from_parent
yield CppItem(test_id, self, self.facade, self._arguments)
-- Docs: https://docs.pytest.org/en/latest/warnings.html
================================================= 3 warnings in 0.11s =================================================
Then it does find the C++ stuff. (Also, any ideas about those warnings?)
So I am not sure how to make it collect both py tests and c++ tests just by running py.test. As a disclaimer, I did not configure anything after installing pytest-cpp with pip. I saw about the cpp_files setting in the ReadMe but it is not clear to me where that configuration file is, and besides it says the default is already *_test executables.
Hello, I am a beginner so I probably just misunderstood how to use this package, however it seems that my installation has trouble collecting tests from C++ files. Here's my situation:
'generator_demo_test.py' that has two test functions, each with its own assert statement
'generator_demo_test.cpp' that #includes gtest.h and has two TEST() functions (but no main() function, if that makes a difference)
I compiled the cpp file with gtest and now have demo_test.exe in the folder with the .py and .cpp files. Then I open a terminal in that folder and type
py.test --collect-onlyand I get the following output:So the c++ tests are ignored.
However, if I type
py.test --collect-only generator_demo_test.exe, then the output is:Then it does find the C++ stuff. (Also, any ideas about those warnings?)
So I am not sure how to make it collect both py tests and c++ tests just by running py.test. As a disclaimer, I did not configure anything after installing pytest-cpp with pip. I saw about the cpp_files setting in the ReadMe but it is not clear to me where that configuration file is, and besides it says the default is already *_test executables.