Оказалось, что Thucydides нормально перехватывает только Exception типа AssertionError. Поэтому необходимо в ключевых местах пробрасывать именно AssertionError.
Например:
public void initializeConnection() throws SQLException { try { Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); } catch (ClassNotFoundException e) { throw e; } String dbHost = null; try { dbHost = getCurrentDBConnectionUrl(DatabaseConst.TEST_SERVER, DatabaseConst.DB_NAME); connection = DriverManager.getConnection(dbHost, DatabaseConst.USER, DatabaseConst.PASS); query = connection.createStatement(); } catch (SQLException e) { throw new SQLException("Cannot connect to Database " + dbHost); } } public String getSomeResults() throws Throwable{ try{ initializeConnection(); //...queries catch(Throwable cause) { throw new AssertionError("Exeception while getting some results", cause); }
В результате видим следующий стек-трейс:
java.lang.AssertionError: Exeception while getting some results at mypackage.Database.getSomeResults(Database.java:219) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at net.thucydides.junit.runners.ThucydidesStatement.evaluate(ThucydidesStatement.java:21) ... Caused by: java.sql.SQLException: Cannot connect to Database jdbc:sqlserver://MyDatabaseIP:1433;databaseName=MyDataBase at mypackage.Database.initializeConnection(Database.java:55) ...