English 中文(简体)
Cypress - Data Driven Testing
  • 时间:2024-03-24 09:11:32

Cypress - Data Driven Testing

Previous Page Next Page  

在固定装置的帮助下,进行了风化数据驱动测试。 添加气压装置,以保持和掌握自动化测试数据。

固定装置在Cypress项目夹(Example.json文档)内。 基本上,它帮助我们从外部档案中获得数据投入。

Fixtures

气压固定装置的夹可在 Java本末端(JSON)或其他格式有文档,数据以“钥匙:价值”为平。

所有测试数据都可以通过一次以上的测试加以利用。 所有固定装置数据必须在前栏目中公布。

Syntax

The syntax for Cypress data Drive test is as follows -


cy.fixture(path of test data)
cy.fixture(path of test data, encoding type)
cy.fixture(path of test data, opts)
cy.fixture(path of test data, encoding type, options)

这里

    编码类型——编码类型(tf-8, asci,等等)用于读文档。

    Opts − Modifies the timeout for response. The default value is 30000ms. The wait time for cy.fixture(), prior throws an exception.

Implementation in example.json

下面是采用数据驱动测试。 json in Cypress -


{
   "email": "abctest@gmail.com",
   "password": "Test@123"
}

Implementation of Actual Test

在Cypress实施实际数据驱动测试如下:


describe( Tutorialspoint Test , function () {
   //part of before hook
   before(function(){
      //access fixture data
      cy.fixture( example ).then(function(signInData){
         this.signInData = signInData
      })
   })
   // test case
   it( Test Case1 , function (){
      // launch URL
      cy.visit("https://www.pnkedin.com/")
      //data driven from fixture
      cy.get( #session_key  )
      .type(this.signInData.email)
      cy.get( # session_password ).type(this.signInData.password)
   });
});

产出如下:

Implementation of Actual Test

产出记录显示,将分送电子邮件和密码田的数值分别为abctest@gmail.com和 Test@123。 这些数据已经通过固定装置进行测试。

Advertisements