0
我有黃瓜的特徵文件(test.feature
)追加字符串基於一個特定的字符串位置的文件
Feature: annotation
Background:
User navigates to Facebook
Given I am on Facebook login page
Scenario: When I enter username as "TOM"
And I enter password as "JERRY"
Then Login should fail
Scenario: When I enter username as "TOM"
And I enter password as "JERRY"
Then Login should fail
But Relogin option should be available
,需要通過添加Java代碼標籤(遞增順序)。像
Feature: annotation
Background:
User navigates to Facebook
Given I am on Facebook login page
@tag1
Scenario: When I enter username as "TOM"
And I enter password as "JERRY"
Then Login should fail
@tag2
Scenario: When I enter username as "TOM"
And I enter password as "JERRY"
Then Login should fail
But Relogin option should be available
標籤將以遞增順序添加。是否有任何可能的方式在字符串上方添加@tag'場景:'
如何使用java代碼實現。任何解決方案。
我試着用以下code.But無法procced追加到字符串的正上方位置「場景:」
int count =0;
BufferedReader bufferedReader = new BufferedReader(new FileReader("test.feature"));
FileWriter writer = new FileWriter("test.feature");
while ((line = bufferedReader.readLine()) != null) {
if (line.trim().startsWith("Scenario")) {
count++;
writer.write("tag"+count);
}
}
//Final Dump data here
writer.close();
bufferedReader.close();
下面的邏輯比較容易,我認爲''讀取file1''輸出到file2''刪除file1''將file2重命名爲file1' –
是的,這是正確的!.....但是現在面臨的是我不能像ab上方的(@ tag1)那樣添加標籤ove每個場景 – chinchu
你爲什麼要做'writer.close();'你在哪裏寫剩下的內容? –