Skip to content

Commit f69d08d

Browse files
Use assertThrows for better failure message.
1 parent f6b5423 commit f69d08d

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

tests/objectbox-java-test/src/test/java/io/objectbox/CursorTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -267,12 +267,12 @@ public void testThrowInEntityConstructor() {
267267

268268
Transaction transaction = store.beginReadTx();
269269
Cursor<TestEntity> cursor = transaction.createCursor(TestEntity.class);
270-
try {
271-
cursor.get(1);
272-
fail("Should have thrown");
273-
} catch (RuntimeException e) {
274-
assertEquals(TestEntity.EXCEPTION_IN_CONSTRUCTOR_MESSAGE, e.getMessage());
275-
}
270+
271+
RuntimeException exception = assertThrows(
272+
RuntimeException.class,
273+
() -> cursor.get(1)
274+
);
275+
assertEquals(TestEntity.EXCEPTION_IN_CONSTRUCTOR_MESSAGE, exception.getMessage());
276276

277277
cursor.close();
278278
transaction.close();

0 commit comments

Comments
 (0)