From 6690a3d191bbffe5aede067e67b84bd3e55cc023 Mon Sep 17 00:00:00 2001 From: David Pursehouse Date: Tue, 25 Sep 2018 11:57:26 +0900 Subject: [PATCH] T0003_BasicTest: Fix incorrect usage of ExpectedException There should only be one statement after the expect(...) method. Any additional statements after the statement that is expected to throw will never be executed in a passing test. This can lead to inappropriately passing tests where later incorrect assertions are skipped by the thrown exception. See https://errorprone.info/bugpattern/ExpectedExceptionChecker Change-Id: I20fecf8fb7a243e9da097e6d03fbf8cd69151bf0 Signed-off-by: David Pursehouse --- .../org/eclipse/jgit/internal/storage/file/T0003_BasicTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/T0003_BasicTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/T0003_BasicTest.java index 02073226d..96caa01a9 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/T0003_BasicTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/T0003_BasicTest.java @@ -333,9 +333,9 @@ public class T0003_BasicTest extends SampleDataRepositoryTestCase { public void test002_CreateBadTree() throws Exception { // We won't create a tree entry with an empty filename // + final TreeFormatter formatter = new TreeFormatter(); expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage(JGitText.get().invalidTreeZeroLengthName); - final TreeFormatter formatter = new TreeFormatter(); formatter.append("", FileMode.TREE, ObjectId.fromString("4b825dc642cb6eb9a060e54bf8d69288fbee4904")); }