2016-11-30 14 views
1

私の仕事では、私の同僚のローカルマシンで失敗しているいくつかのテストがありますが、私がテストを実行している代理人ではありません。私はあなたが分度器を使用すると、それぞれが制御フローに入れられ、順番に実行されるという印象を受けました。私たちの同僚のマシンで見ていることは、以前の約束が解決されていないにもかかわらず、後続のものが実行されているということです。私は仕事に関する詳細を取り除きました。うまくいけば、以下のコードスニペットは何が起こっているのかを理解するのに十分です。分度器とControlFlowを誤解していますか?

分度器の理解が間違っている、または同僚のマシンに問題がある可能性がありますか?

"use strict"; 

describe('Test Title', function() { 
    let fetchedData, 
    createdData; 

beforeAll(()=> globalHelper.logIn()); 
afterAll(()=> globalHelper.logOut()); 

it("Precondition: set to clean state", function() { 
    environmentHelper.cleanEnvironment(); 
}); 

it("Get data from server", function() { 
    fetchDataFromServer() 
    .then((result) => { 
     fetchedData = result; 

    });//we expect execution of the test to stop until this promise is resolved and an error is thrown or the code inside the then is executed 
}); 

it("Next Step", function() { 
    //do some things 
}); 

it("Next step", function(){ 
    //do more things 
}); 

it("Navigate to page",() => { 
    //navigate to page 
}); 

it("create some data", function() { 
    //create some data 
}); 

it("another step", function() { 
    //do even more things 
}); 

it("Clean up", function() { 
    environmentHelper.removeCreatedData(createdData); 
    }); 

}); 

助けてください。事前のおかげで

+2

'it(...) 'によって表されるテストは、他のテストとは独立していると考えられます。あなたの例では、それらをステップとして使用していますが、これは悪い習慣です。 –

答えて

0

私は約束はangular/jasminewdに基づいてブロック内で解決するために分度器を待つべき

it("Get data from server", function() { 
    fetchDataFromServer().then((result) => { 
     console.log('data fetched from server complete'); 
     fetchedData = result; 
    }).catch(err => { 
     console.error('something bad happened here); 
    }); 
    //we expect execution of the test to stop until this promise is resolved and an error is thrown or the code inside the then is executed 
    }); 

    it("Next Step", function() { 
    console.log("next step"); 
    //do some things 
    }); 

fetchDataFromServerに余分なロギングを追加し、多分catch文を持っているでしょう。 controlFlowの場合、selenium-webdriverは約束をキューに入れて順番に解決します。したがって、browser.getまたはelement(by.css('')).clickを送信すると、順番に処理されます。

関連する問題