Пример #1
0
 @Test
 public void noArgs() throws Exception {
   makeScenarioTable("|scenario|myScenario|\n");
   assertEquals("myScenario", st.getName());
   assertEquals(0, st.getInputs().size());
   assertEquals(0, st.getOutputs().size());
   assertFalse(st.isParameterized());
 }
Пример #2
0
 @Test
 public void parameterizedNameWithOneArgInMiddle() throws Exception {
   makeScenarioTable("|scenario|login _ user|name|\n");
   assertEquals("LoginUser", st.getName());
   Set<String> inputs = st.getInputs();
   assertEquals(1, inputs.size());
   assertTrue(inputs.contains("name"));
   assertTrue(st.isParameterized());
 }
Пример #3
0
 @Test
 public void oneInputArgWithTrailingName() throws Exception {
   makeScenarioTable("|scenario|myScenario|input|trailer|\n");
   assertEquals("MyScenarioTrailer", st.getName());
   Set<String> inputs = st.getInputs();
   assertEquals(1, inputs.size());
   assertTrue(inputs.contains("input"));
   assertEquals(0, st.getOutputs().size());
   assertFalse(st.isParameterized());
 }
Пример #4
0
 @Test
 public void parameterizedNameWithTwoArgs() throws Exception {
   makeScenarioTable("|scenario|login user _ password _|name,password|\n");
   assertEquals("LoginUserPassword", st.getName());
   Set<String> inputs = st.getInputs();
   assertEquals(2, inputs.size());
   assertTrue(inputs.contains("name"));
   assertTrue(inputs.contains("password"));
   assertTrue(st.isParameterized());
 }
Пример #5
0
 @Test
 public void simpleNameWithUnnamedArguments() throws Exception {
   makeScenarioTable("|scenario|f|a||b|\n");
   assertEquals("f", st.getName());
   Set<String> inputs = st.getInputs();
   assertEquals(2, inputs.size());
   assertTrue(inputs.contains("a"));
   assertTrue(inputs.contains("b"));
   assertFalse(st.isParameterized());
 }
Пример #6
0
 @Test
 public void manyInputsWithTrailer() throws Exception {
   makeScenarioTable("|scenario|login user|user name|with password|password|now|\n");
   assertEquals("LoginUserWithPasswordNow", st.getName());
   Set<String> inputs = st.getInputs();
   assertEquals(2, inputs.size());
   assertTrue(inputs.contains("userName"));
   assertTrue(inputs.contains("password"));
   assertEquals(0, st.getOutputs().size());
   assertFalse(st.isParameterized());
 }
Пример #7
0
 @Test
 public void manyInputsAndOutputs() throws Exception {
   makeScenarioTable(
       "|scenario|login user|user name|with password|password|giving message|message?|and status|login status?|\n");
   assertEquals("LoginUserWithPasswordGivingMessageAndStatus", st.getName());
   Set<String> inputs = st.getInputs();
   assertEquals(2, inputs.size());
   assertTrue(inputs.contains("userName"));
   assertTrue(inputs.contains("password"));
   Set<String> outputs = st.getOutputs();
   assertEquals(2, outputs.size());
   assertTrue(outputs.contains("message"));
   assertTrue(outputs.contains("loginStatus"));
   assertFalse(st.isParameterized());
 }
Пример #8
0
 @Test
 public void getArgumentsFromParameterizedInvocation() throws Exception {
   makeScenarioTable("|scenario|login user _ password _|name,password|\n");
   String[] arguments = st.matchParameters("login user Bob password xyzzy");
   assertEquals(2, arguments.length);
   assertEquals("Bob", arguments[0]);
   assertEquals("xyzzy", arguments[1]);
 }
Пример #9
0
 private ScenarioTable makeScenarioTable(String pageContents) throws Exception {
   WikiPageUtil.setPageContents(root, pageContents);
   TableScanner ts = new HtmlTableScanner(root.getData().getHtml());
   Table t = ts.getTable(0);
   testContext = new MockSlimTestContext();
   st = new ScenarioTable(t, "id", testContext);
   st.appendInstructions(instructions);
   return st;
 }