SpecFlow - 集成测试(消息体系结构+调度问题)

时间:2015-01-06 13:07:21

标签: .net testing messaging specflow

我们目前正在使用SpecFlow进行一些集成测试。使用消息传递架构和基于时间的测试时,这有些挑战。

对于消息传递架构,我们目前正在流动: 1)进行API调用。 2)SpecFlow每隔x次检查队列,直到它为空,然后继续。 3)空队列=完成处理,这意味着留下了断言。

对于基于时间的测试,我们目前对如何实现这一点并不了解。例如,我们有时会在将来安排一条消息。当它返回时它会产生一个结果。我们现在要做的是确保调度时间限制为让我们根据输入说一分钟,然后在断言前等待一分钟。这是有效的,但随着越来越多的测试被编写并且SpecFlow需要等待越来越多,测试变得更慢,我不想要。

其他人如何处理这些问题?

1 个答案:

答案 0 :(得分:0)

我一直在咀嚼这个问题一天,而我认为我可能想出了一个黑客工作解决方案。首先,在他们自己的功能中隔离所有消息测试。第一个场景只创建将来发布的所有消息,然后等待1分钟。之后,每个场景都会对其中一个正在测试的消息进行断言:

Feature: Publishing messages in the future
    ...

Scenario: Setting up the rest of the tests
    Given the message "foo" will be published 1 minute from now
    And the message "bar" will be published 1 minute from now
    And I wait 1 minute

Scenario: Foo got published
    Then the message "foo" should have been published

Scenario: Bar got published
    Then the message "bar" should have been published

这样你就等了一分多钟,然后做了几个断言 - 每个场景都有一个断言。