茉莉花中的条件测试用例
Conditional test case in jasmine
我在写茉莉花。我希望当网站的响应正常时(网站上传 - 待定 200)。
运行 规范中的它(测试用例),当站点加载失败时,它的(测试用例)将不会 运行。
我在所有功能之前检查了网站的响应。
现在,在每个它做出不同的事情时,如果响应(保存在全局变量中)为真,我会检查条件
我怎样才能像以前一样在全球乐趣中做到这一点?
let response;
describe('', ()=>{
beforeAll (async () => {
//this function return the statusCode of http request
response= await sendQuery('Http://...');
})
beforeEach(async(), =>{
});
it('', async()=> {
if (response = 200){
//do somsing 1...
}
it('', async()=> {
if (response = 200){
//do somsing 2...
}
it('', async()=> {
if (response = 200){
//do somsing 3...
}
v
it('', async()=> {
if (response = 200){
//do somsing 4...
}
it('', async()=> {
if (response = 200){
//do somsing 5...
}
it('', async()=> {
if (response = 200){
//do somsing 6...
}
你的配置中有这样的东西
async onPrepare() {
global.response = await sendQuery('Http://...');
if (global.response !== 200) {
throw new Error(`Status is ${response}`); // may not be needed actually, but I'll leave it
await browser.close();
await process.exit(1);
}
}
global.response
将在您的规格中可用
我在写茉莉花。我希望当网站的响应正常时(网站上传 - 待定 200)。
运行 规范中的它(测试用例),当站点加载失败时,它的(测试用例)将不会 运行。
我在所有功能之前检查了网站的响应。
现在,在每个它做出不同的事情时,如果响应(保存在全局变量中)为真,我会检查条件
我怎样才能像以前一样在全球乐趣中做到这一点?
let response;
describe('', ()=>{
beforeAll (async () => {
//this function return the statusCode of http request
response= await sendQuery('Http://...');
})
beforeEach(async(), =>{
});
it('', async()=> {
if (response = 200){
//do somsing 1...
}
it('', async()=> {
if (response = 200){
//do somsing 2...
}
it('', async()=> {
if (response = 200){
//do somsing 3...
}
v
it('', async()=> {
if (response = 200){
//do somsing 4...
}
it('', async()=> {
if (response = 200){
//do somsing 5...
}
it('', async()=> {
if (response = 200){
//do somsing 6...
}
你的配置中有这样的东西
async onPrepare() {
global.response = await sendQuery('Http://...');
if (global.response !== 200) {
throw new Error(`Status is ${response}`); // may not be needed actually, but I'll leave it
await browser.close();
await process.exit(1);
}
}
global.response
将在您的规格中可用