]> source.dussan.org Git - jgit.git/commit
ConfigTest: Fix tests for getting empty config value as int 81/130181/1
authorDavid Pursehouse <david.pursehouse@gmail.com>
Sat, 29 Sep 2018 03:54:37 +0000 (12:54 +0900)
committerDavid Pursehouse <david.pursehouse@gmail.com>
Sat, 29 Sep 2018 03:54:37 +0000 (12:54 +0900)
commit00698f9e27439a0a5a7556a8df1d5e94e0a7e8ba
treef0c4fa6fb47826a31ba60e65a4e54349b6b99859
parent873b0b775435275865d93871906e76adccdbf53a
ConfigTest: Fix tests for getting empty config value as int

The tests were set up to expect an IllegalArgumentException when
the Config.getInt method was called with a section.key that has
not been set, or explicitly set to an empty string.

However, the IllegalArgumentException never gets thrown because
the getInt method returns the provided default ("1"), and because
there was no call to "fail" after getInt, the incorrect behavior
of the test was not noticed.

Remove the try/catch around getInt, and instead assert that the
expected default value is returned.

Found by Error Prone, which reported:

  Not calling fail() when expecting an exception masks bugs

See https://errorprone.info/bugpattern/MissingFail

Change-Id: Ie8e692aba9fb8523241fb8f298d57493923d9f78
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ConfigTest.java