WillemJiang commented on a change in pull request #10: SCB-1400 Complement and
improve unit test
URL: https://github.com/apache/servicecomb-toolkit/pull/10#discussion_r309008963
##########
File path:
common/src/test/java/org/apache/servicecomb/toolkit/common/FileUtilsTest.java
##########
@@ -32,33 +33,44 @@
@Test
public void createDirectoryTest() {
- try {
- FileUtils.createDirectory(null);
- } catch (IOException e) {
- assertEquals("Path is null", e.getMessage());
- }
-
Path path;
try {
path = Files.createTempDirectory("");
FileUtils.createDirectory(path.toFile().getCanonicalPath());
} catch (IOException e) {
fail("Run 'createDirectoryTest' failed and unexpected to catch
IOException: " + e.getMessage());
}
+
+ try {
+ FileUtils.createDirectory(null);
+ } catch (IOException e) {
+ assertEquals("Path is null", e.getMessage());
+ return;
+ }
+
+ fail("Run 'createDirectoryTest' failed, expected to catch IOException but
not");
}
@Test
public void getFilesGroupByFilenameTest() {
+ boolean succeed = false;
+
try {
+ succeed = false;
FileUtils.getFilesGroupByFilename(null);
Review comment:
It can be changed to like this
try {
FileUtils.getFilesGroupByFilename(null);
Assert.fail("Except RuntimeException Here");
} catch (RuntimeException e) {
assertThat(e, is(oops));
}
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services