Reputation: 55
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.
So my question is how are tests organised in cypress? and can we run multiple tests on the same instance?
Upvotes: 0
Views: 179
Reputation: 121
Cypress uses mocha for the structure of the tests.
describe() block in mocha groups the tests.
it() block tells that this is a test.
e.g.
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
})
})
Upvotes: 2
Reputation: 77
Everything you need is in the official documentation : 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()
})
})
Upvotes: 1