...
- StringQuestion
- BooleanQuestion
- ChoiceQuestion
- FqnQuestion
Unit testing the new API
Because arguments can easily be passed from code with the new API it becomes easier to write unit tests for commands. For example, these a few tests for the "ls" command.
Code Block |
---|
@RunWith(MockitoJUnitRunner.class)
public class LsCommandTest {
@Spy @InjectMocks LsCommand cmd = new LsCommand();
@Mock Navigator m_navigator;
@Before
public void setup() {
when(m_navigator.getCurrentDir()).thenReturn(new File( System.getProperty("user.dir"), "test/ls-testdir").toPath());
}
@Test
public void withoutArgs() {
List<File> result = cmd.execute();
assertThat(result.size(), is(4));
}
@Test
public void recursive() {
List<File> result = cmd.execute("-R");
assertThat(result.size(), is(8));
}
@Test
public void files() {
List<File> result = cmd.execute("-F");
assertThat(result.size(), is(2));
}
@Test
public void recursiveFilesOnly() {
List<File> result = cmd.execute("-R","-F");
assertThat(result.size(), is(6));
}
@Test
public void name() {
List<File> result = cmd.execute("file1.*");
assertThat(result.size(), is(1));
}
@Test
public void combined() {
List<File> result = cmd.execute("-R", "-F", ".*file1.*");
assertThat(result.size(), is(3));
}
} |
Next steps
I have migrated Bootstrap core, the core plugins and the Amdatu plugins. It would be great to get some help migrating the other plugins. To make sure we're getting to a release I would like to propose a release date for 1.0.0 at September 5 (we also have a LT meeting planned that day).
...