自动规划自动回归测试执行顺序的框架?

发布于 2024-11-02 02:25:12 字数 1172 浏览 4 评论 0原文

我目前正在为一个相对复杂的应用程序实现测试套件。该应用程序是Java &基于 Spring 的 Web 前端。前端测试也可以用 Java 编写(使用 Silk4J 及其自动化客户端)。实际上编写测试不是问题,这是简单的部分。开始变得棘手的是各个测试的执行顺序。

目前我们正在使用 JUnit 编写测试。由于 JUnit 是一个单元测试工具,测试的执行顺序并不固定。如果我们只是为应用程序的每个模块创建测试,我们很快就会遇到麻烦。一些测试必须依赖其他部分才能正常工作,并且其他模块的某些数据可用。我可以通过将应用程序状态初始化为预定义状态然后执行其测试的方式为每个模块编写测试,但是必须清理和准备状态将是一项相当大的工作。更复杂的测试需要跨多个模块的大量准备和测试场景。

我正在寻找的是一个测试框架,其中每个测试都可以以某种方式定义其需求以及它测试/提供的服务(创建用户功能的测试实际上可以创建用户......至少应该如此)。现在我不想硬编码哪个测试使用哪些数据以及按哪个顺序运行,因为确定顺序非常复杂,并且对应用程序的更改将使得有必要完全重构测试。

例如,我的“create-user-test”创建用户是实际检查用户是否正确创建的副作用。对我来说,这个功能是否使用 userA、userB 或 userC 进行测试并不重要,只要经过测试即可。如果我现在有另一个测试“create-account-test”,需要一个只有 userC 满足的用户,那么测试系统应该知道“哦...... create-account-test 需要 userC,尚未创建,但通过传递userC 到我的“create-user-test”,这将创建它,因此在最终执行中,它在“create-account-test”之前使用 userC 运行“create-user-test”,并在此使用“create-user-test”的副作用。 -user-test”来创建 通过检查我的测试

的需求和服务,这样的系统应该能够创建一个包含每个测试至少一次的非循环图(从而测试整个功能)。不必为每个测试准备/拆除应用程序状态,或者如果无法创建这样的图表,则触发错误,至少这样我可以创建仍然可维护的巨大测试场景

。我用谷歌搜索了一下,如果有人的话。 allready 致力于这样一个框架。不幸的是我找不到类似的东西。

现在我希望有人能指导我使用工具或告诉我为什么这是一个完全糟糕的主意。 “嘿……好主意……还没有人创造出这样的东西”的回应……肯定会极大地浪费我的下班后休闲时间,因为在那种情况下,我可能会开始开发这样的工具;-)

Chris

I'm currently working on the implementation of a testsuite for a relatively complex application. The application is Java & Spring based with a web frontend. The Frontend-Tests can be written in Java too (using Silk4J and their automation-client). Actually writing the tests is not the issue, this is the easy part. Where it starts getting tricky, is the order in which individual tests can be executed.

Currently we are writing our tests using JUnit. As JUnit is a Unit-Testing tool the order in which the tests are executed is not fixed. If we simply create the tests for every module of the application we quickly run into trouble. Some tests have to rely on other parts to be working correctly and that certain data from other modules is available. I could write the tests for every module in a way that is initializes the applications state to a pre-defined state and then executes its tests, but having to clean and prepare the state would be quite an effort. The more complex tests require a vast amount of preparation and test scenarios that go accross multiple modules.

What I'm looking for is a testing framework, in which each test can somehow define its requirements and what service it tests/provides (A test of the create-user-feature can actually create users ... at least it should). Now I don't want to hard-code which test is run with which data and in which order, because it is extremely complex to determin the order and changes to the application would make it neccesary to completely refactor the tests.

For example my "create-user-test" creates users as a side-effect of actually checking that users are correctly created. To me it doesn't matter if this functionality is tested using userA, userB or userC, just as long as it is tested. If I now have another test "create-account-test" that requires a user that only userC sattisfies, then the test system should know "Oh ... create-account-test needs userC, that has not been created yet but by passing userC to my "create-user-test", that would create it. So in the final execution it runs "create-user-test" with userC before "create-account-test" and hereby uses the side-effect of "create-user-test" to create the state needed by the "create-account-test".

By inspecting the requirements and the services of my tests. Such a system should be able to create a non-cyclic graph containing each test at least once (hereby testing the entire functionality) but without having to prepare/teardown the applications state for every test or fire an Error if it is somehow not possible to create such a graph. At least this way I could create huge test scenarios that would still stay maintainable.

I know this is a somewhat complex. I googled a while, if somebody allready worked on such a framework. Unfortunately I couldn't find anything similar.

Now I'm hoping for someone here to guide me to a tool OR tell me why this is a totally bad idea. A response of "Hey ... great idea ... nobody created such a thing yet" ... would certainly kill my after-work leasure time dramatically, because in that case I would propably start developing such a tool ;-)

Chris

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

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

发布评论

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

评论(2

软的没边 2024-11-09 02:25:12

像 jUint 这样的工具通常不支持排序测试的运行,因为它通常被认为是单元测试的不好做法。在单元测试中,您希望确保每个测试完全独立于其他测试,并且没有外部依赖项。

但是您没有进行单元测试,因此尝试使用 jUnit 将会导致您想要实现的目标与工具实现者设计 jUnit 要做的事情之间发生冲突......

不过,您似乎正在尝试做很多事情。您希望能够运行测试并让测试工具找出并创建您需要的数据。这是一个非常艰巨的任务......我不知道有任何工具可以完成您所要求的所有事情,但是有很多工具可以通过一些努力来提供您想要的大部分内容。

像 Robotframework 这样的测试框架允许您指定测试运行的顺序。它可能更适合您想要实现的目标。

但在测试之前总是需要做一些工作来设置环境。我通常将需要特定配置或数据集的测试收集在一起。然后,我在运行这组测试之前运行这些步骤。它减少了每次测试前进行配置和数据设置的需要。但它也降低了复杂性,因此易于管理。

Tools like jUint don't typically support ordering the running of tests because it's generally considered a bad practice for unit testing. In unit testing, you want to ensure each test is completely independant of other tests, and has no external dependencies.

But you're not doing unit testing, so attempting to use jUnit is going to cause conflicts between what you are trying to achieve, and what the tool implementers designed jUnit to do...

You seem to be trying to do an awful lot though. You want to be able to run a test and have a test tool figure out and create and data you need. That's a really tall order there... I don't know of any tool that does everything you are asking, but there are plenty of tools that can provide most of what you want, with some effort.

A test framework like Robotframework allows you to specify the order in which tests run. It's probably more suited to what you are trying to achieve.

But there will always be some work to do in order to set up your environment before testing. I generally collect tests together that require a particular configuration or set of data. I then run those steps just before running that set of tests. It cuts down on the need to do configuration and data setup before every test. But it also reduces complexity so it is manageable.

戒ㄋ 2024-11-09 02:25:12

我们使用 TestNG 和 Silk4J 来创建顺序回归测试(有些测试短至 10 分钟,有些测试超过 12 小时)长的)。所有测试都按特定顺序执行 - 当发生超级严重错误时,某些测试会触发“跳过所有剩余测试”。

We use TestNG with Silk4J to create sequenced regression tests (Some tests are as short as 10 minutes and some are over 12 hours long). All of the tests execute in a specific order - and some tests trigger a 'skip all remaining tests' when a super-critical error occurs.

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