如何设置测试项目(命名空间、有用的帮助对象等)?

发布于 2024-10-08 07:37:58 字数 994 浏览 7 评论 0原文

我的团队正在尝试制定一些自动化测试指南。具体来说,我们感兴趣的是我们的测试项目中将存在哪些类型的类、如何设置名称空间等等。这是我们到目前为止所提出的。

解决方案资源管理器项目中的视图

  • :MyProject.Testing
    • 文件夹:功能 A
      • 类:TestFixture1
      • 类:TestFixture2
    • 类:ConstantManager
    • 类:StateManager
    • 类:EntityBuilder
    • 类:ScenarioBuilder

我的测试装置按功能组织。这本质上模仿了我的主解决方案命名空间,因此如果我在主项目中有类似 MyProject.Dao 的命名空间,那么在我的测试项目中我有 MyProject.Testing.Dao。

我还添加了一些辅助类。

  • ConstantManager:存储数据库 ID 等,以供测试期间所需的可重用常量
  • StateManager:管理每次测试之前重置状态(可以用原始文件替换测试修改的文件,重置数据库等)
  • EntityBuilder:创建可用于测试的域实体的实例
  • ScenarioBuilder:从 EntityBuilder 中获取实体并将它们组合成可用于测试的场景重复用于多次测试。例如,这可能是填充树,或设置特定属性等。我认为 ScenarioBuilder 将继承 EntityBuilder(或者可能完全替换 EntityBuilder)

虽然我已将 ConstantManager、EntityBuilder 和 ScenarioBuilder 显示为直接位于测试项目下,如果情况需要,实际上可以为每个函数(例如在功能 A 下)对这些类进行特定定义。

那么,我做错了什么以及我应该做什么?谢谢!

My team is trying to set up some guidelines for automated testing. Specifically, we are interested in what types of classes will exist in our testing project, how the namespaces will be set up, etc. This is what we have come up with so far.

The view from the solution explorer

  • Project: MyProject.Testing
    • Folder: Functionality A
      • Class: TestFixture1
      • Class: TestFixture2
    • Class: ConstantManager
    • Class: StateManager
    • Class: EntityBuilder
    • Class: ScenarioBuilder

I have my test fixtures organized by function. This essentially mimics my main solution namespaces so if I have something like MyProject.Dao as a namespace in my main project, in my testing project I have MyProject.Testing.Dao.

I also added some helper classes.

  • ConstantManager: Stores database id's, etc for reusable constants needed during tests
  • StateManager: Manages reseting the state before each test (could be replacing a file modified by a test with the original, resetting a db, etc)
  • EntityBuilder: Creates instances of our domain entities that can be used for testing
  • ScenarioBuilder: Takes the entities from the EntityBuilder and combines them into scenarios that can be reused for multiple tests. For example, this could be populating a tree, or setting specific properties, etc. I'm thinking ScenarioBuilder will inherit EntityBuilder (or perhaps replace EntityBuilder altogether)

While I have shown the ConstantManager, EntityBuilder, and ScenarioBuilder as being directly under the testing project, there could actually be specific definitions of these classes for each function (under Functionality A for example) if the situation calls for it.

So, what am I doing wrong and what should I be doing? Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

甜心 2024-10-15 07:37:58

您可能需要考虑使用 .UnitTests 后缀所有单元测试项目,以及使用 .IntegrationTests 后缀所有集成测试项目。这意味着您的自动化构建服务器可以区分哪些项目应包含在 CI 构建(单元测试项目)中,哪些项目应包含在夜间构建(单元测试和集成测试项目)中。

You might want to consider postfixing all unit test projects with .UnitTests, and all integration test projects with .IntegrationTests. This means that your automated build server can differentiate between which projects should be included in a CI build (unit test projects), and which should be included in the nightly build (unit test and integration test projects).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文