英文:
What to tests in ci run vs pytest, and why
问题
使用ci.yml
文件中的run
方式主要适用于持续集成(CI),通常用于自动化构建和部署流程。这种方式适合执行集成测试、部署前的自动化检查等任务。
另一种方式是在名为test
的文件夹下创建test_...
文件,并通过运行pytest tests
在CI流水线中执行它们。这适合单元测试、功能测试等更细粒度的测试,通常用于检查代码中的特定功能或组件。
选择哪种方式取决于您的测试需求和工作流程。持续集成中的run
方式适合执行整体集成和自动化检查,而pytest
方式适合更详细的测试用例。
英文:
I have a python repo in github. If I understood it correctly there are mainly two ways in which tests can be automated:
- using
run
in aci.yml
file - using
test_...
files under a folder calledtest
(at root level) and then execute them in the ci pipeline by runningpytest tests
What type of tests are more suitable for each of these options? And why?
答案1
得分: 0
PyTest:pytest非常适用于编写和执行单元测试,并在CI流水线中常常包括使用pytest编写的单元测试。单元测试侧重于“在隔离的情况下测试单个组件或代码单元”。它们有助于验证每个代码单元的功能是否正确,是否符合其预期行为。这些测试通常执行速度更快,并提供有关单个代码单元正确性的即时反馈。
CI测试:集成测试旨在测试“系统中不同组件如何协同工作”。它们验证各种代码单元之间的集成点和交互是否正常工作。集成测试在捕获可能由系统不同部分之间的交互引发的问题方面非常有价值。
英文:
Nvm, I found this:
PyTest: pytest is well-suited for writing and executing unit tests, and it's common to include unit tests written with pytest in the CI pipeline. Unit tests are focused on testing individual components or units of code in isolation
. They help verify that each unit of code functions correctly and meets its expected behavior. These tests are typically faster to execute and provide immediate feedback on the correctness of individual units of code.
CI Tests: Integration tests are designed to test how different components of a system work together
. They verify that the integration points and interactions between various units of code function correctly. Integration tests are valuable in catching issues that may arise due to interactions between different parts of the system.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论