0

In JavaScript, the library Jest has a delightful semantic - expect.assertions(number) which verifies that a certain number of assertions are called during a test, for example of async code:

test('doAsync calls both callbacks', () => {
  expect.assertions(2);
  function callback1(data) {
    expect(data).toBeTruthy();
  }
  function callback2(data) {
    expect(data).toBeTruthy();
  }

  doAsync(callback1, callback2);
});

Is there a similar semantic available in JUnit or other Java unit testing libraries?

If so, please feel very welcome to give an example, such as using CompleteableFuture or as appropriate.

pzrq
  • 1,626
  • 1
  • 18
  • 24

0 Answers0