单元测试数据?

发布于 2024-07-05 15:48:55 字数 430 浏览 11 评论 0原文

我们的软件管理来自不同来源的大量数据源:实时复制数据库、自动 FTP 传输的文件、计划运行数据库存储过程以缓存来自链接服务器的数据快照以及许多其他获取数据的方法。

我们需要验证和验证此数据:

  • 是否发生了导入
  • ,数据是否合理(空值、行数等),
  • 是否与其他值一致(也许我们有多个类似数据源)
  • 数据 数据和导入需要手动提示

在很多方面这就像单元测试:需要进行多种类型的检查,只需将新的检查添加到列表中,然后重新运行每个类的测试以响应特定的事件。 已经有很好的 GUI 用于运行测试,甚至可能能够安排它们。

这是一个好方法吗? 是否有更好的、类似的通用数据验证模式?

我们是一家 .NET 商店,Windows Workflow (WF) 是否是一个更好、更灵活的解决方案?

Our software manages a lot of data feeds from various sources: real time replicated databases, files FTPed automatically, scheduled running of database stored procedures to cache snapshots of data from linked servers and numerous other methods of acquiring data.

We need to verify and validate this data:

  • has an import even happened
  • is the data reasonable (null values, number of rows, etc.)
  • does the data reconcile with other values (perhaps we have multiple sources for similar data)
  • is it out of data and the import needs manually prompting

In many ways this is like Unit Testing: there are many types of check to make, just add a new check to the list and just re-run each class of test in response to a particular event. There are already nice GUIs for running tests, perhaps even being able to schedule them.

Is this a good approach? Are there better, similarly generalised, patterns for data validation?

We're a .NET shop, would Windows Workflow (WF) be a better more flexible solution?

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

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

发布评论

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

评论(2

ゝ偶尔ゞ 2024-07-12 15:48:55

单元测试与您需要做的事情不同。 它更像是集成测试或验收测试。 但这不是重点。

您的系统对于验证进入系统的数据有很高的要求。 数据通过多种方式进入系统,我认为需要以不同的方式对其进行验证。

工作流适用于设计和控制易于更改或需要人工干预的业务流程(逻辑)。 当涉及到验证主题时,它是不可知的。 但是,将验证过程托管为工作流程可能是一个好主意,因为工作流程设计灵活、寿命长且能够进行人工干预。 在工作流状态机框架内托管验证过程将允许您在运行时为不同类型的数据导入定义验证策略。

您需要设计一个验证框架,其逻辑在很大程度上依赖于组合而不是继承。 将数据导入系统并验证的所有不同方式分解为原子步骤。 按职责对这些步骤进行分组,并使用实现对象执行每个步骤所需的最基本、最少的属性和方法创建接口。 创建由这些不同接口组成的基类。 从这个框架中,您可以混合和匹配适合特定导入或验证步骤的实现。

最后一件事。 工作流被序列化为 xaml 以进行长期存储。 您的类也应该是可 xaml 序列化的,以使从活动到存储库的转换尽可能顺利和简单。

Unit testing is not analogous to what you need to do. Its more along the lines of integration testing or acceptance testing. But that's beside the point.

Your system has a heavy requirement for validation of data coming into the system. Data comes into the system by various means, and I would assume it needs to be verified in different ways.

Workflow is good for designing and controlling business processes (logic) that are apt to change or require human intervention. It is agnostic when it comes to the subject of validation. However, hosting your validation process as a workflow may be a good idea, as workflows are designed to be flexible, long living and capable of human intervention. Hosting your validation process within a workflow state machine framework would allow you to define validation strategies for different types of data import at runtime.

You need to design a validation framework that relies heavily on composition over inheritance for its logic. Break apart all the different ways that data can be imported into the system and validated into atomic steps. Group those steps by responsibility and create interfaces with the barest, most minimum properties and methods required for an implementing object to perform each. Create base classes that are composed of these different interfaces. From this framework you can mix and match implementations that suit the particular import or validation step.

One last thing. Workflows are serialized to xaml for long term storage. Your classes should be xaml serializable as well to make the transition from activity to repository and back again as smooth and simple as possible.

走过海棠暮 2024-07-12 15:48:55

测试这些数据的有效性似乎是合理的。 您可以将其称为单元测试,也可以不将其称为单元测试,这是您的选择。 我不会。 使用您认为最适合这项工作的工具 - 我不知道 WF(WebForms?)是什么意思。

通过自动测试,您可以获得最大的好处。无论什么是自动的并且适合您,都是好的。

Testing this data for validity seems reasonable. You may or may not call it Unit Testing, that's your choice. I wouldn't. Use the tool you find best for this job - I don't know what do you mean by WF (WebForms?).

The most benefit you get by testing this automatically. Whatever is automatic and works for you, is good.

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