简体   繁体   English

赛普拉斯如何组织测试

[英]How are tests organised in cypress

We are currently looking at swapping from selenium to cypress for our automated End to End tests as it looks as if it could stop some of the wait headaches caused by selenium. 我们目前正在考虑从硒换成柏树以进行自动化的“端到端”测试,因为这似乎可以阻止硒引起的一些令人头疼的麻烦。

As the login time can take a while we use a [OneTimeSetUp] at the start of a test class in NUnit to to do our initial log in then we run our tests from there. 由于登录时间可能需要一段时间,因此我们在NUnit中的测试类的开头使用[OneTimeSetUp]进行初始登录,然后从此处运行测试。

So my question is how are tests organised in cypress? 所以我的问题是赛普拉斯如何组织测试? and can we run multiple tests on the same instance? 我们可以在同一个实例上运行多个测试吗?

Cypress uses mocha for the structure of the tests. 赛普拉斯使用摩卡咖啡进行测试的结构。

describe() block in mocha groups the tests. 摩卡咖啡中的describe()块将测试分组。

it() block tells that this is a test. it()块表明这是一个测试。

eg 例如

  describe('Login Functionality', function() {

      it('Check Login with Correct Credentials', function() {
           //Your code
      })

     it('Check Login with Incorrect Username', function() {
           //Your code
      })

      it('Check Login with Incorrect Password', function() {
           //Your code
      })


    })

Everything you need is in the official documentation : https://docs.cypress.io/guides/core-concepts/writing-and-organizing-tests.html#Hooks 您需要的所有内容都在官方文档中: https : //docs.cypress.io/guides/core-concepts/writing-and-organizing-tests.html#Hooks

Enjoy Cypress! 享受赛普拉斯!

Sample : 样品:

  beforeEach(function () {
    cy.visit('/users/new')
    cy.get('#first').type('Johnny')
    cy.get('#last').type('Appleseed')
  })

  it('displays form validation', function () {
    cy.get('#first').clear() // clear out first name
    cy.get('form').submit()
    cy.get('#errors').should('contain', 'First name is required')
  })

  it('can submit a valid form', function () {
    cy.get('form').submit()
  })
})

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

相关问题 带有剑道下拉菜单的 Cypress 测试 - Cypress tests with kendo dropdown 如何使用赛普拉斯 Cucumber 预处理器实现单个测试的重试? - How to achieve retries for individual tests using Cypress Cucumber Preprocessor? 如何在 cypress 中使用旧版 chrome 运行我的测试 - How can I run my tests with older chrome version in cypress 赛普拉斯 - 从 beforeEach 中排除测试 - Cypress - exclude tests from beforeEach 有没有办法在赛普拉斯测试中设置断点? - Is there a way to set breakpoints in Cypress tests? 如何跨多个规范/测试文件组织具有可重用功能的赛普拉斯测试 - How to organize Cypress tests with reusable functions across multiple spec/test files 从另一个赛普拉斯测试文件调用赛普拉斯测试 - Calling Cypress tests from another Cypress test file 检查幻灯片切换开关的状态在赛普拉斯测试中不起作用 - Checking states of Slide toggle not working in Cypress Tests Cypress:信用卡支付的自动测试 - Cypress: automatic tests for credit card payment 赛普拉斯电子商务 E2E 测试:如何测试支付沙箱,例如亚马逊? 多域测试 - Cypress E2E Tests for eCommerce: How to test payment sandbox e.g. Amazon? Multi domain testing
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM