简体   繁体   English

您是否在验收测试或单元测试中测试所有无效电子邮件和密码的组合,以进行登录?

[英]Do you test all combinations of invalid emails and passwords in Acceptance tests or in Unit tests for a login?

I've written an acceptance test for a login using Codeception, which tests whether a user can: 我已经使用Codeception为登录编写了验收测试,该测试测试用户是否可以:

1. Login with valid credentials 1.使用有效凭证登录

The login with valid credentials opens the page, fills the fields, submits, and checks to see the user is now in the dashboard. 使用有效凭据的登录名将打开页面,填充字段,提交并检查用户是否现在在仪表板中。

2. Not login with invalid credentials 2.不使用无效的凭证登录

The login with invalid credentials does the same, but on submit I check for a message saying the username and password combination is incorrect 使用无效凭据的登录名是相同的,但是在提交时,我会检查一条消息,指出用户名和密码组合不正确

3. Not login with empty credentials 3.不使用空凭据登录

The login with empty credentials does the same, but on submit I check for messages in elements that appear under the form inputs indicating the field is required. 使用空凭据的登录名是相同的,但是在提交时,我检查表单输入下方显示的元素中的消息,指示必填字段。

This seems like an almost acceptable suite of tests for a login (it might not be I really wouldn't know), but then it doesn't test different combinations of invalid usernames (email addresses) and password (minlength of 8 characters), but I'm not sure whether trying to submit an array of potentially invalid emails, and checking the UI is what you want to do in an acceptance test... is it more of a unit test? 这似乎是一套几乎可以接受的登录测试套件(我可能真的不知道),但是它并没有测试无效的用户名(电子邮件地址)和密码(最少8个字符)的不同组合,但我不确定是否要尝试提交一系列可能无效的电子邮件,并检查UI是否要在验收测试中执行的操作……这更像是单元测试吗?

Thinking ahead where do you draw the line on acceptance tests as this is a relatively small example, but some of the forms coming up are quite large so if I thought of a 30+ input form what should I be trying to achieve in my acceptance test and what should be spun off to a unit test? 提前考虑一下您在哪里进行验收测试的界限,因为这是一个相对较小的示例,但是即将出现的某些表格相当大,因此,如果我想到了30多种输入表格,那么我应该如何在验收测试中达到目标以及应该从单元测试中分离出什么?

Unit tests and acceptance tests serve different purposes, provide you a different level of detail and usually are written by different people (software engineer and test engineer correspondingly). 单元测试和验收测试有不同的用途,可为您提供不同级别的详细信息,并且通常由不同的人员(相应地由软件工程师和测试工程师)撰写。

In case your login acceptance tests fail you will know that login functionality is not working as intended. 万一您的登录接受测试失败,您将知道登录功能无法正常工作。 In case your unit tests fail you will know what piece of code is not working as intended because it has access to the actual code (eg your password hashing algorithm is not working). 万一您的单元测试失败,您将知道哪个代码段无法正常工作,因为它可以访问实际代码(例如,密码哈希算法不起作用)。

When writing test cases it makes sense to have a look at Equivalence Class Partitioning . 在编写测试用例时,有必要看一下等价类分区 For the password, you'll have to check: empty password, 7-character password, 8-character password, password with the length between 0 and 7, password with invalid characters, etc (depends on your requirements). 对于密码,您必须检查:空密码,7个字符的密码,8个字符的密码,长度在0到7之间的密码和无效字符的密码等(取决于您的要求)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Codeception。 用于接受测试的测试数据库,或用于纯PHP的功能测试 - Codeception. Test database for acceptance tests, or functional tests for pure PHP 使用laravel运行单元测试时,如何测试App :: error()实现? - When running unit tests with laravel, how do you test your App::error() implementations? 使用symfony 2的Codeception验收测试 - Using Codeception acceptance tests with symfony 2 PHP单元测试:是否可以测试致命错误? - PHP Unit Tests: Is it possible to test for a Fatal Error? Symfony 4 php 单元测试 - 没有执行测试 - Symfony 4 php unit test - no tests executed 您在更新原始源代码后是否更新了单元测试? - Do you update your Unit Tests after updating your original source code? 在 Laravel 8 的单元测试中调用未定义的方法 Tests\\Unit\\TopPageTest::get() - Call to undefined method Tests\Unit\TopPageTest::get() in Unit test in Laravel 8 如何为异步微服务创建验收测试 - How to create acceptance tests for async micro services 使用Codeception验收测试连接到多个数据库 - Connecting to multiple databases with Codeception acceptance tests 设置测试数据库以用于Codeception(Laravel)中的验收测试 - Setup testing database for acceptance tests in Codeception (Laravel)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM