在 DB 中为 jBehave 测试故事设置测试数据

发布于 2024-12-22 05:35:05 字数 143 浏览 4 评论 0原文

我希望完整地使用 jBehave 作为集成测试框架,因此在开始特定的测试故事之前,我需要某种明确的方法在数据库中设置测试数据,类似于将 DbUnit 与 jUnit 一起使用,其中我们定义测试数据 XML对于每个测试用例。有没有办法用或不用 DbUnit 来实现这一目标?

I wish to use jBehave in completeness as an integration testing framework and therefore I need some definite way of setting up the Test data in the database before I begin with a particular test story something similar to using DbUnit with jUnit where we define the test data XMLs for each test case. Is there a way to achieve this with or with out DbUnit ?

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

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

发布评论

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

评论(1

临走之时 2024-12-29 05:35:05

JBehave 示例中包含的 spring-security 示例正是这样做的。它使用 DbUnit 作为 @BeforeStory 清除数据库。

如果您需要特定数据,那么您可能需要创建 GivenStories 或让 Gives 加载特定数据文件。

@Given("the gold status users")
public void loadGoldStatusUsers() {
    dbunitLoader.load("/goldStatusUsers.xls");
}

The spring-security example that is contained in JBehave examples does exactly that. It uses DbUnit to wipe out the database as a @BeforeStory.

If you want specific data, then you might want to create GivenStories or have Givens that load specific data files.

@Given("the gold status users")
public void loadGoldStatusUsers() {
    dbunitLoader.load("/goldStatusUsers.xls");
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文