You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

tests.md 2.3 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. # Tests
  2. Tests are automatically run via GitHub actions. There are two workflows:
  3. 1. [build.yml](https://github.com/microsoft/autogen/blob/main/.github/workflows/build.yml)
  4. 1. [openai.yml](https://github.com/microsoft/autogen/blob/main/.github/workflows/openai.yml)
  5. The first workflow is required to pass for all PRs (and it doesn't do any OpenAI calls). The second workflow is required for changes that affect the OpenAI tests (and does actually call LLM). The second workflow requires approval to run. When writing tests that require OpenAI calls, please use [`pytest.mark.skipif`](https://github.com/microsoft/autogen/blob/b1adac515931bf236ac59224269eeec683a162ba/test/oai/test_client.py#L19) to make them run in only when `openai` package is installed. If additional dependency for this test is required, install the dependency in the corresponding python version in [openai.yml](https://github.com/microsoft/autogen/blob/main/.github/workflows/openai.yml).
  6. Make sure all tests pass, this is required for [build.yml](https://github.com/microsoft/autogen/blob/main/.github/workflows/build.yml) checks to pass
  7. ## Running tests locally
  8. To run tests, install the [test] option:
  9. ```bash
  10. pip install -e."[test]"
  11. ```
  12. Then you can run the tests from the `test` folder using the following command:
  13. ```bash
  14. pytest test
  15. ```
  16. Tests for the `autogen.agentchat.contrib` module may be skipped automatically if the
  17. required dependencies are not installed. Please consult the documentation for
  18. each contrib module to see what dependencies are required.
  19. See [here](https://github.com/microsoft/autogen/blob/main/notebook/contributing.md#testing) for how to run notebook tests.
  20. ## Skip flags for tests
  21. - `--skip-openai` for skipping tests that require access to OpenAI services.
  22. - `--skip-docker` for skipping tests that explicitly use docker
  23. - `--skip-redis` for skipping tests that require a Redis server
  24. For example, the following command will skip tests that require access to
  25. OpenAI and docker services:
  26. ```bash
  27. pytest test --skip-openai --skip-docker
  28. ```
  29. ## Coverage
  30. Any code you commit should not decrease coverage. To run all unit tests, install the [test] option:
  31. ```bash
  32. pip install -e."[test]"
  33. coverage run -m pytest test
  34. ```
  35. Then you can see the coverage report by
  36. `coverage report -m` or `coverage html`.