【发布时间】:2020-03-15 03:22:32
【问题描述】:
当我按下“运行所有规格”button 或使用运行赛普拉斯中所有文件的运行命令时,它会按字母顺序运行所有测试文件,所以我不希望这样。
我想用我自己的规则对它们进行排序。
假设我在聊天应用测试中有 3 个步骤。
- 可以连接聊天应用
- 可以连接聊天
- 用户可以发消息吗
我想测试每一步,而不是相互束缚。 我的意思是,测试自己的功能之一。 我的做法如下
chat_app_connect.spec.js
describe('Server Connecting Test', () => {
it('Visit Server page', () => {
cy.visit('https://chat.page..');
});
it('Check welcome messages', () => {
cy.contains('Live Support');
cy.contains('Hello, Stranger');
});
it('Check URL and status of circle', () => {
// URL
cy.url()
.should('include', '/hello');
// Status Circle
cy.get('circle')
.should('have.class', 'positive');
});
});
chat_connect.spec.js
import './chat_app_connect.spec.js';
describe('Chat Connecting Test', () => {
it('Type customer name', () => {
cy.get('input')
.clear()
.type('E2E Test');
});
it('Click to the submit button', () => {
cy.get('.submit-button')
.click();
});
it('Check URL and status of circle', () => {
// URL
cy.url()
.should('equal', 'https://client.dev.octopus.chat/');
// Status Circle
cy.get('circle', { timeout: 5000 })
.should('have.class', 'positive');
});
});
chatting.spec.js
import './chat_connect.spec.js';
describe('Chatting Tests', () => {
it('Type a test message then press Enter and check the message if it sent', () => {
// Type
cy.get('#chat-message')
.clear()
.type('Hey I\'m a test message{enter}');
// Check the message
cy.get('.message-list')
.should('contain', 'Hey I\'m a test message');
});
});
正如您所见,每个测试都相互关联,这意味着当我尝试仅测试 catting 功能时,它会调用每个测试,并且将测试整个测试。
我不知道这是否正确。
在这种情况下我应该怎么做,或者这是一种可以接受的方式
【问题讨论】: