Skip to content

Commit

Permalink
Doc: add some details of UnitTest and Converge in Documentation (#2752)
Browse files Browse the repository at this point in the history
* add some details of UnitTest and Converge

* Update docs/CONTRIBUTING.md

Co-authored-by: Chun Cai <amoycaic@gmail.com>

---------

Co-authored-by: Chun Cai <amoycaic@gmail.com>
  • Loading branch information
WHUweiqingzhou and caic99 committed Jul 25, 2023
1 parent 93090d3 commit c2d273b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ Configure your VS Code settings as `"C_Cpp.clang_format_style": "file"` (you can

## Adding a unit test

We use GoogleTest as our test framework. Write your test under the corresponding module folder at `abacus-develop/tests`, then append the test to `tests/CMakeLists.txt`. If there are currently no unit tests provided for the module, do as follows. `module_base` provides a simple demonstration.
We use [GoogleTest](https://github.com/google/googletest) as our test framework. Write your test under the corresponding module folder at `abacus-develop/tests`, then append the test to `tests/CMakeLists.txt`. If there are currently no unit tests provided for the module, do as follows. `module_base` provides a simple demonstration.

- Add a folder named `test` under the module.
- Append the content below to `CMakeLists.txt` of the module:
Expand Down Expand Up @@ -142,8 +142,9 @@ To add a unit test:
)
```

- Build with `-D BUILD_TESTING=1` flag. You can find built testing programs under `build/source/<module_name>/test`.
- Build with `-D BUILD_TESTING=1` flag, `cmake` will look for `GoogleTest` in the default path (usually `/usr/local`); if not found, you can specify the path with `-D GTEST_DIR`. You can find built testing programs under `build/source/<module_name>/test`.
- Follow the installing procedure of CMake. The tests will move to `build/test`.
- Considering `-D BUILD_TESTING=1`, the compilation will be slower compared with the case `-D BUILD_TESTING=0`.

## Debugging the codes

Expand Down Expand Up @@ -187,6 +188,8 @@ This feature requires using GCC compiler. We use `gcov` and `lcov` to generate c
cmake --build build --target test ARGS="-V --timeout 21600"
```

If configuration fails unfortunately, you can find [required files](https://github.com/baixiaokuang/CMake-codecov/tree/master/cmake) (including three *.cmake and llvm-cov-wrapper), and copy these four files into `/abacus-develop/cmake`. Alternatively, you can define the path with option `-D CMAKE_CURRENT_SOURCE_DIR`.

3. Generate HTML report.

```bash
Expand Down

0 comments on commit c2d273b

Please sign in to comment.