跳转到主要内容
Chinese, Simplified

测试用例是一组条件或变量,测试人员将在这些条件或变量下确定应用程序、软件系统或网站是否符合规范并按预期运行。测试用例可以是肯定的,也可以是否定的,这意味着它测试的是正确的功能还是缺失的功能。

什么是测试用例?

测试用例是一组条件或变量,测试人员将在这些条件或变量下确定应用程序、软件系统或其功能之一是否正常工作。测试用例主要有三种类型:

  • 阳性测试案例:在这些案例中,被测试的系统有望正常工作。这些测试旨在表明系统能够处理有效的输入并产生预期的输出。
  • 阴性测试案例:这些是被测试系统预计会失败的案例。这些测试有助于确保系统能够优雅地处理无效输入,并在必要时产生错误消息或其他适当的输出。
  • 破坏性测试案例:这些案例中,被测试的系统被故意破坏,以测试其恢复能力。这些测试有助于确保系统能够承受意外故障,并且仍然正常工作。

什么是阳性检测案例?

阳性测试用例是验证系统或应用程序在有效或预期输入条件下正确运行的能力的测试。

  • 阳性测试案例的示例包括验证表单提交的正确数据输出、验证用户是否能够成功登录应用程序,或确认支付交易是否成功。
  • 积极的测试用例对软件质量保证至关重要,有助于确保系统按预期运行,并在给出有效输入时产生正确的结果。
  • 阳性测试用例用于评估系统或应用程序在给定有效输入或理想条件下的行为。
  • 这些测试有助于确保应用程序按预期运行,并确保用户体验令人满意。
  • 应该为应用程序的所有特性和功能编写阳性测试用例,并且应该包括边界值和边缘用例的测试用例。
  • 阳性测试用例通常由对测试的应用程序或系统有深入了解的QA工程师或测试人员编写。
  • 测试人员应该清楚地了解功能和期望的结果,并且应该熟悉应用程序的源代码和设计。

什么是阴性测试案例?

阴性测试用例用于测试系统的无效输入和意外行为。它们的设计目的是确保系统在给定无效或意外输入时按预期运行。

  • 阴性测试案例很重要,因为它们可以发现错误,否则这些错误将无法被发现。
  • 负测试用例是那些旨在证明系统在给定无效输入时不能按预期工作的测试。例如,登录系统的阴性测试用例可能输入了不正确的用户名和密码组合。这将确保系统不会对没有正确凭据的用户进行身份验证。
  • 阴性测试用例也可以用于检查意外行为。例如,搜索引擎的否定测试用例可能是输入具有意外格式的查询。这将确保系统在给出意外输入时不会提供意外结果。
  • 阴性测试用例对于确保系统安全也很重要。
  • 它们可用于测试输入验证、身份验证、授权、访问控制和其他安全措施。例如,身份验证系统的阴性测试用例可能输入了无效的用户名或密码。这将确保系统不会对没有正确凭据的用户进行身份验证。

什么是破坏性测试案例?

破坏性测试用例是一种软件测试,旨在识别系统暴露在极端条件下时发生的软件故障。这些测试包括故意将系统置于异常或极端条件下,以确定其断裂点和造成的损坏程度。

  • 破坏性测试的目的是在现场发生潜在的系统故障之前识别这些故障,并帮助确保系统能够承受这些条件。
  • 破坏性测试可能涉及多种情况,例如故意引入不正确的数据,使系统过载,请求超过其处理能力,或者模拟可能导致硬件故障的极端温度。
  • 这些测试旨在模拟真实世界的条件,并揭示系统中任何隐藏的弱点。这有助于在系统发布给用户之前识别和解决任何问题,确保产品更加可靠。
  • 破坏性测试通常在受控环境中进行,在受控环境下可以密切监测测试条件,并可以快速将系统恢复到其原始状态。
  • 这使得跟踪测试结果、识别任何问题和开发解决方案变得更加容易。

破坏性测试并不是软件测试的唯一类型。其他类型的软件测试包括功能测试、回归测试和性能测试。每种类型的软件测试都有自己的好处,可以与破坏性测试结合使用,以提供系统的全面视图。

阳性测试用例与阴性测试用例与破坏性测试用例

以下是阳性测试用例、阴性测试用例和破坏性测试用例之间的差异:

Factor Positive Test CasesNegative Test CasesDestructive Test Cases
FunctionalityTest cases that test the basic functionality of the software.Test cases that test for errors or unexpected behavior.Test cases that delete or modify data.
UsabilityTest cases that test for user-friendliness and easy navigation.Test cases that test for confusing interfaces or difficult navigation.Test cases that delete user data or preferences.
PerformanceTest cases that test for fast loading times and response times.Test cases that test for slow loading times and response times.Test cases that delete cached data or user preferences.
SecurityTest cases that test for proper authentication and authorization.Test cases that test for vulnerabilities and exploits.Test cases that delete user data or preferences.
DesignTest cases are tests that are designed to ensure that a system works as expected.Test cases are tests that are designed to ensure that a system does not work as expected.Test cases are tests that are designed to deliberately break a system in order to test its robustness.
DataA positive test case is run on unaltered dataA negative test case is run on altered dataA destructive test case is run on permanently altered data.
Example
  • The software should allow a user to input their username and password in order to log in.
  • The software should allow the user to view all of their past and current orders.
  • The software should allow the user to view the details of a specific order.
  • The software should allow the user to search for an order by order number.
  • The software should not allow a user to log in with an invalid username and password.
  • The software should not allow the user to view orders they do not have permission to access.
  • The software should not allow the user to view the details of an order they do not have permission to access.
  • The software should not allow the user to search for an order by an invalid order number.
  • The software should allow a user to log in with a valid username and password.
  • The software should allow the user to view all of their past and current orders.
  • The software should allow the user to view the details of a specific order.
  • The software should allow the user to search for an order by order number.

如何选择使用哪种类型的测试用例?

在决定使用哪种类型的测试用例时,需要考虑以下几个因素:

  • 你测试的目的:如果你试图在你的软件中找到错误,那么你会想要使用阳性的测试用例。这些测试软件的预期行为。如果您试图了解软件在遇到意外输入时的反应,那么您将希望使用阴性测试用例。这些测试软件的意外行为。最后,如果您试图确定您的软件是否能够处理极端条件(如大量数据),那么您将希望使用破坏性测试用例。这些人故意试图破坏软件,看看它是如何响应的。
  • 时间:正测试用例和负测试用例可以相对快速地编写,因为它们只需要几个不同的输入值。破坏性测试用例需要更长的时间来编写,因为它们必须非常具体和精心制作,才能有机会破坏软件。
  • 成本:破坏性测试用例是迄今为止最昂贵的测试用例类型,因为它们通常需要专门的硬件和/或环境才能正常运行。阳性和阴性测试用例的成本要低得多,因为它们可以在没有特殊要求的任何系统上运行。考虑所有这些因素将帮助您决定哪种类型的测试用例适合您的需求。

 

原文地址
https://www.geeksforgeeks.org/positive-vs-negative-vs-destructive-test-cases/
本文地址
Article

微信

知识星球

微信公众号

视频号