コード例 #1
0
  @Test
  public void testGlobalsAttributeWithDeepNestedScript() throws IOException {
    File dir = tempDir();
    File foo =
        tempScript(
            "foo.mt", "Button 1FOO${foo} Tap\nScript bar.mt Run\nButton 2FOO${foo} Tap", dir);
    tempScript(
        "bar.mt",
        "Button 1BAR${foo} Tap\nGlobals * Set foo=234\nScript baz.mt Run\nButton 2BAR${foo} Tap",
        dir);
    tempScript(
        "baz.mt", "Button 1BAZ${foo} Tap\nGlobals * Set foo=345\nButton 2BAZ${foo} Tap", dir);

    task.setScript(foo);
    task.setAgent("iOS");
    task.setGlobals("foo=123");

    task.execute();

    assertThat(server.getCommands(), notNullValue());
    assertThat(server.getCommands().size(), is(6));
    assertThat(server.getCommands().get(0).getCommand(), is("Button 1FOO123 Tap"));
    assertThat(server.getCommands().get(1).getCommand(), is("Button 1BAR123 Tap"));
    assertThat(server.getCommands().get(2).getCommand(), is("Button 1BAZ234 Tap"));
    assertThat(server.getCommands().get(3).getCommand(), is("Button 2BAZ345 Tap"));
    assertThat(server.getCommands().get(4).getCommand(), is("Button 2BAR345 Tap"));
    assertThat(server.getCommands().get(5).getCommand(), is("Button 2FOO345 Tap"));

    assertThat(Globals.getGlobals().size(), is(1));
    assertThat(Globals.getGlobal("foo"), is("345"));
  }
コード例 #2
0
  @Test
  public void testGlobalsAttribute() throws IOException {
    File dir = tempDir();
    File foo = tempScript("foo.mt", "Button ${foo} Tap ${bar}", dir);

    task.setScript(foo);
    task.setAgent("iOS");
    task.setGlobals("foo=123 bar=\"Bo Bo\"");

    task.execute();

    assertThat(server.getCommands(), notNullValue());
    assertThat(server.getCommands().size(), is(1));
    assertThat(server.getCommands().get(0).getCommand(), is("Button 123 Tap \"Bo Bo\""));

    assertThat(Globals.getGlobals().size(), is(2));
    assertThat(Globals.getGlobal("foo"), is("123"));
    assertThat(Globals.getGlobal("bar"), is("Bo Bo"));
  }
コード例 #3
0
  @Test
  public void testPropertiesFile() throws IOException {
    File dir = tempDir();
    tempScript("globals.properties", "foo=123\nbar=Bo Bo", dir);
    File foo = tempScript("foo.mt", "Button ${foo} Tap\nButton ${bar} Tap", dir);

    task.setScript(foo);
    task.setAgent("iOS");

    task.execute();

    assertThat(server.getCommands(), notNullValue());
    assertThat(server.getCommands().size(), is(2));
    assertThat(server.getCommands().get(0).getCommand(), is("Button 123 Tap"));
    assertThat(server.getCommands().get(1).getCommand(), is("Button \"Bo Bo\" Tap"));

    assertThat(Globals.getGlobals().size(), is(2));
    assertThat(Globals.getGlobal("foo"), is("123"));
    assertThat(Globals.getGlobal("bar"), is("Bo Bo"));
  }
コード例 #4
0
  @Before
  public void before() throws IOException {
    task = new RunTask();
    task.setHost(HOST);
    task.setPort(PORT);

    proj = new Project();
    task.setProject(proj);

    server = new PlaybackCommandServer(new TestHelper(), PORT);
    Globals.clear();
  }
コード例 #5
0
  @Test
  public void testBothGlobalsAttributeAndPropertiesFile() throws IOException {
    File dir = tempDir();
    tempScript("globals.properties", "foo=123\nbar=Bo Bo", dir);
    File foo = tempScript("foo.mt", "Button ${foo} Tap\nButton ${bar} Tap", dir);

    task.setScript(foo);
    task.setAgent("iOS");
    task.setGlobals("foo=234");

    task.execute();

    assertThat(server.getCommands(), notNullValue());
    assertThat(server.getCommands().size(), is(2));
    // because the globals attribute overrides the properties file
    assertThat(server.getCommands().get(0).getCommand(), is("Button 234 Tap"));
    assertThat(server.getCommands().get(1).getCommand(), is("Button \"Bo Bo\" Tap"));

    assertThat(Globals.getGlobals().size(), is(2));
    assertThat(Globals.getGlobal("foo"), is("234"));
    assertThat(Globals.getGlobal("bar"), is("Bo Bo"));
  }