功能测试理念:测试功能还是需求?
我目前正在编写一些功能测试,我开始想知道这两者之间最好的理念是什么。
情况
我的应用程序有一些安全页面,需要用户组拥有正确的凭据才能访问。这些用户分为 2 个组:“协作者组”和“负责组”。向各小组颁发证书。
可能的原理
解决方案 1:测试凭据,也称为测试功能。
对于每个安全页面,我测试了 2 个用户的访问:其中一个用户的 正确的凭证,只有这个, 以及一个没有正确凭证的人。
优点:仅测试页面针对特定凭据的安全性
缺点:不测试“最终”应用程序行为,正如用户(和用户)所希望的那样客户。
解决方案 2:测试组,也称为测试要求
对于每个安全页面,我测试了 每个组的用户的访问权限,以及 检查是否只有允许的组 访问受保护的页面。
优点:根据客户端(和用户)的需要测试“最终”应用程序行为。
缺点:
- 测试与测试装置紧密相连
- 。如果业务规则发生变化或创建更多组,则测试必须更改。
谢谢。
I'm currently writing some functional tests, and I started wondering what's the best philosophy between these two.
Situation
My application has some secured page, that need the user's group to have the right credentials to have access. These user are split into 2 groups : the 'collaborator group', and the 'accountable group'. Credentials are given to the groups.
Possible philosophies
Solution 1: Tests the credentials a.k.a. Test the features.
For each secured page, I test the
access with 2 users : one with the
right credential, and only this one,
and one without the right credential.
Pros: Tests only the fact that the page is secured against a specific credential
Cons: Doesn't test the "final" application behavior, as wanted (and user) by the client.
Solution 2: Test the groups a.k.a. test the requirements
For each secured page, I test the
access with a user of each group, and
check that only the allowed groups
gain access to the secured page.
Pros: Tests the "final" application behavior, as wanted (and user) by the client.
Cons:
- Tests are tieds with the tests fixtures
- Tests will have to change if the business rules changes or if more groups are created.
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为第二解决方案是好的。只要凭证与组关联,就会对其进行测试。
这是最重要的部分。功能测试旨在在每种可能的情况下测试最终应用程序。如果您想测试您的凭据与用户或组具有相同的行为,您最好使用单元测试。
如果应用程序的业务发生变化,您的测试用例将始终需要更新。正如您对单元测试所做的那样。如果您修改函数的代码,请检查单元测试是否仍然能够控制每种情况。功能测试也是如此。
维护测试(以及它们需要运行的装置)是一项非常繁琐的任务,但这是确保代码强大的唯一方法。
希望有帮助。
I think the second solution is the good one. The credentials will be tested as far as they are associated with a group.
This is the most important part. Functional tests aims to test the final application in every possible cases. If you want to test the fact that your credentials have the same behavior with a user or a group, you'd better use unit tests.
Your tests cases will always have to be updated if the business of your application changes. As you do with your unit tests. If your modify the code of a function, you check if your unit tests are still able to control each case. It's the same way with functional tests.
Maintaining your tests (and the fixtures they need to run) is a very tedious task, but it's the only way to ensure you're code is strong.
Hope it helped.
我会做这两项测试。正如您所指出的,第一个不需要更新,但正在测试一个至关重要的事实,即没有权限的用户无法访问。第二个是更全面的测试,就像@TimotheeMartin 指出的那样,当代码发生变化时,测试总是需要更新。
I would do both tests. The first one like you pointed out, does not need updating, but is testing the crucially important fact that users without entitlements do not have access. The second is the more comprehensive test and like @TimotheeMartin pointed out, tests will always need to be updated when the code changes.