Is there any test framework or any other way to test async methods in Java?
<p>I have a bunch of async functions in java that I want to test. I would like to have a functionality where the main thread waits until all the tests are done. The method signature of these functions looks like as follows</p>

<pre><code>public class Callback {
    public void onSucess(Result result) {
        return result.getLastName(); 
    }
}

public class client{

    public static void getLastNameAsync(String firstname, Callback cb);

    public static void getLastNameAsync(String middlename, Callback cb);
    ...................................
    ...................................
    ...................................
    Imagine there are more functions like this 
}
</code></pre>

<p>I want to be be able to test the client class as follows </p>

<pre><code>    public void TestClient(){
        Client client = new Client();
        client.getLastNameAsync("Brandon", new callback());
        client.getLastNameAsync("kyle", new callback());
        ....................
        ....................
        ....................

        Imagine I have to test more functions like this
    }
</code></pre>

<p>countDownLatch seems to be a solution however I need to know the number of method calls I am invoking and even if I do that seems to be a hacky solution because I need to instantiate as below</p>

<pre><code>CountDownLatch latch = new CountDownLatch(#number of methods calls in my TestClient);
The trick again here is knowing #number of methods calls in my TestClient
</code></pre>

<p>open to any kind of advice or solution.</p>