์๋ ,
๋ด ๊ธฐ๋ฅ์ ํธ์ถํ๋ ์๋๋ฆฌ์ค๋ฅผ ์ด๋ป๊ฒ ์ ์ ์์ต๋๊น? ๋ด ๊ธฐ๋ฅ ์๋๋ฆฌ์ค์์ ํ๊ทธ๋ฅผ ์ฌ์ฉํ๋ ๋ฐฉ๋ฒ์ ๋ฌด์์ ๋๊น?
์ค์ ๋ก ํ ๊ฐ์ง ์๋๋ฆฌ์ค๊ฐ ์์ต๋๋ค.
Feature: create module feature
As a admin
I want to use create module
<strong i="8">@createModule</strong>
Given I am logged as 'ADMIN'
And I am on "/admin/create"
Then The "book_id" field should be empty
๋ด ๊ธฐ๋ฅ์์ ๋ด ํ๊ทธ @createModule ์ ์ฌ์ฉํ๊ณ ์ถ์ต๋๋ค.
this.Then(/^The "?([^"]*)"? field should be empty$/, function (el) {
if (myModule === @createModule) {
...
} else if {
...
}
return main_po.checkIsEmptyElement(this, el);
});
ํธ์ถ๋๋ ์๋๋ฆฌ์ค๋ฅผ ์ง์ ํ๊ธฐ ์ํด @createModule ํ๊ทธ๋ฅผ ๋ฐ๊ณ ์ถ์ต๋๋ค. ๋๋ ๋ค๋ฅธ ๋์์ผ๋ก ์ด๋ค ์๋๋ฆฌ์ค๊ฐ ๋ด ๊ธฐ๋ฅ์ ํธ์ถํ๋์ง ์๊ณ ์ถ์ต๋๋ค.
ํ๊ทธ๋ ์ค์ด-js๋ฅผ ์คํํ ๋ ์คํํ ์๋๋ฆฌ์ค๋ฅผ ์ ํํ๋ ๋ฐ ์ฌ์ฉ๋ฉ๋๋ค(README ์ฐธ์กฐ). ํ์ฌ ๋จ๊ณ์๋ ํ์ฌ ์คํ ์ค์ธ ์๋๋ฆฌ์ค๋ฅผ ์ ์ ์๋ ๋ฐฉ๋ฒ์ด ์์ต๋๋ค. ์๋๋ฆฌ์ค ์๋์ ๋ชจ๋ ๋จ๊ณ๋ ์ธ๊ณ ์ธ์คํด์ค๋ฅผ ๊ณต์ ํฉ๋๋ค(๋จ๊ณ ์ ์์์ this
๋ฅผ ํตํด ์ก์ธ์ค).
ํด๊ฒฐ :
๋๋ ์ถ๊ฐํ๋ค :
this.Before(function (scenario, callback) {
var tags = scenario.getTags();
this.current_module = tags[0].getName();
callback();
});
๊ทธ๋ฆฌ๊ณ ๋ด ๊ธฐ๋ฅ :
this.Then(/^The "?([^"]*)"? field should be empty$/, function (el) {
if (this.current_module === @createModule) {
...
} else if {
...
}
return main_po.checkIsEmptyElement(this, el);
});
@jechazelle ์๋ฃจ์ ์ ๊ฒ์ํด ์ฃผ์ ์ ๊ฐ์ฌํฉ๋๋ค. ๋ค๋ฅธ ์ฌ์ฉ ์ฌ๋ก์ ๋ํด ๋์ผํ ๊ธฐ๋ฅ์ด ํ์ํฉ๋๋ค. :)
์ค์ด-js 3.2.1์์ ์ฌ์ฉ
Before({timeout: 20000}, async function(testCase) {
this.tags = testCase.pickle.tags.map((tag) => tag.name);`
...
}
๋ด๊ฐ ๊ทธ๊ฒ์ ์ฌ์ฉํ๋ ์ด์ ๋ ํน์ ๋จ๊ณ ๊ตฌํ์ด ์๋ ค์ง ์๋๋ฆฌ์ค ํ์ ์งํฉ์ ๋ํด ์คํจํ๊ณ ์๊ธฐ ๋๋ฌธ์ ์ถ์ ์์คํ ์์ ์ค์ํ์ง ์์ ๊ฒฐํจ ํฐ์ผ์ ๋ง๋ค๊ณ ์คํจํ ์๋๋ฆฌ์ค์ ํฐ์ผ# ํ๊ทธ๋ฅผ ์ง์ ํ ๋ค์ ๋ ผ๋ฆฌ๋ฅผ ์ถ๊ฐํ์ต๋๋ค. this.tags์ ํฐ์ผ ๋ฒํธ๊ฐ ํฌํจ๋ ๊ฒฝ์ฐ ๋จ๊ณ ๊ตฌํ์์ '๋ณด๋ฅ ์ค'์ ๋ฐํํฉ๋๋ค.
์ด๋ฅผ ํตํด ๋น๋๋ฅผ ๋ น์์ผ๋ก ๋๋๋ฆด ์ ์์ผ๋ฉฐ ๊ฒฐํจ์ ์์ ํ ์ง ์ฌ๋ถ๋ฅผ ๊ฒฐ์ ํ๋ ๊ถํ์ด ์์ต๋๋ค.
์ด ์ค๋ ๋๋ ๋ซํ ํ ์ต๊ทผ ํ๋์ด ์์๊ธฐ ๋๋ฌธ์ ์๋์ผ๋ก ์ ๊ฒผ์ต๋๋ค. ๊ด๋ จ ๋ฒ๊ทธ์ ๋ํ ์ ๋ฌธ์ ๋ฅผ ์ฌ์ญ์์ค.
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
ํด๊ฒฐ :
๋๋ ์ถ๊ฐํ๋ค :
๊ทธ๋ฆฌ๊ณ ๋ด ๊ธฐ๋ฅ :