From 790ddb2983bce01d2d0b5b1049d5576fa0c136a8 Mon Sep 17 00:00:00 2001 From: Robin Rosenberg Date: Sat, 5 Nov 2011 16:52:24 +0100 Subject: Don't throw away the stack trace when tests fail Most unexpected exceptions are completely useless yielding message like "null" or "3" or in the best cases something reasonable, but still out of context. Just declare the test as throwing an exception. That will retain the full stack trace leading to the point of failure without using a debugger or changing the code. Change-Id: Id2454d328d1aa665606ae002de2c3805fe7baa8e --- .../org/eclipse/jgit/api/LsRemoteCommandTest.java | 100 +++++++++------------ 1 file changed, 42 insertions(+), 58 deletions(-) (limited to 'org.eclipse.jgit.test/tst/org/eclipse/jgit/api/LsRemoteCommandTest.java') diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/LsRemoteCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/LsRemoteCommandTest.java index 7d3a55e2af..ac563b0618 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/LsRemoteCommandTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/LsRemoteCommandTest.java @@ -44,7 +44,6 @@ package org.eclipse.jgit.api; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.fail; import java.io.File; import java.util.Collection; @@ -79,69 +78,54 @@ public class LsRemoteCommandTest extends RepositoryTestCase { } @Test - public void testLsRemote() { - try { - File directory = createTempDirectory("testRepository"); - CloneCommand command = Git.cloneRepository(); - command.setDirectory(directory); - command.setURI("file://" - + git.getRepository().getWorkTree().getPath()); - command.setCloneAllBranches(true); - Git git2 = command.call(); - addRepoToClose(git2.getRepository()); - - - LsRemoteCommand lsRemoteCommand = git2.lsRemote(); - Collection refs = lsRemoteCommand.call(); - assertNotNull(refs); - assertEquals(6, refs.size()); - } catch (Exception e) { - fail(e.getMessage()); - } + public void testLsRemote() throws Exception { + File directory = createTempDirectory("testRepository"); + CloneCommand command = Git.cloneRepository(); + command.setDirectory(directory); + command.setURI("file://" + git.getRepository().getWorkTree().getPath()); + command.setCloneAllBranches(true); + Git git2 = command.call(); + addRepoToClose(git2.getRepository()); + + + LsRemoteCommand lsRemoteCommand = git2.lsRemote(); + Collection refs = lsRemoteCommand.call(); + assertNotNull(refs); + assertEquals(6, refs.size()); } @Test - public void testLsRemoteWithTags() { - try { - File directory = createTempDirectory("testRepository"); - CloneCommand command = Git.cloneRepository(); - command.setDirectory(directory); - command.setURI("file://" - + git.getRepository().getWorkTree().getPath()); - command.setCloneAllBranches(true); - Git git2 = command.call(); - addRepoToClose(git2.getRepository()); - - LsRemoteCommand lsRemoteCommand = git2.lsRemote(); - lsRemoteCommand.setTags(true); - Collection refs = lsRemoteCommand.call(); - assertNotNull(refs); - assertEquals(3, refs.size()); - } catch (Exception e) { - fail(e.getMessage()); - } + public void testLsRemoteWithTags() throws Exception { + File directory = createTempDirectory("testRepository"); + CloneCommand command = Git.cloneRepository(); + command.setDirectory(directory); + command.setURI("file://" + git.getRepository().getWorkTree().getPath()); + command.setCloneAllBranches(true); + Git git2 = command.call(); + addRepoToClose(git2.getRepository()); + + LsRemoteCommand lsRemoteCommand = git2.lsRemote(); + lsRemoteCommand.setTags(true); + Collection refs = lsRemoteCommand.call(); + assertNotNull(refs); + assertEquals(3, refs.size()); } @Test - public void testLsRemoteWithHeads() { - try { - File directory = createTempDirectory("testRepository"); - CloneCommand command = Git.cloneRepository(); - command.setDirectory(directory); - command.setURI("file://" - + git.getRepository().getWorkTree().getPath()); - command.setCloneAllBranches(true); - Git git2 = command.call(); - addRepoToClose(git2.getRepository()); - - LsRemoteCommand lsRemoteCommand = git2.lsRemote(); - lsRemoteCommand.setHeads(true); - Collection refs = lsRemoteCommand.call(); - assertNotNull(refs); - assertEquals(2, refs.size()); - } catch (Exception e) { - fail(e.getMessage()); - } + public void testLsRemoteWithHeads() throws Exception { + File directory = createTempDirectory("testRepository"); + CloneCommand command = Git.cloneRepository(); + command.setDirectory(directory); + command.setURI("file://" + git.getRepository().getWorkTree().getPath()); + command.setCloneAllBranches(true); + Git git2 = command.call(); + addRepoToClose(git2.getRepository()); + + LsRemoteCommand lsRemoteCommand = git2.lsRemote(); + lsRemoteCommand.setHeads(true); + Collection refs = lsRemoteCommand.call(); + assertNotNull(refs); + assertEquals(2, refs.size()); } } -- cgit v1.2.3