tags:

views:

101

answers:

3
+1  Q: 

API testing tools

We have developed an API for an application using Java. Are there any special tools or products avaialble to test an API?

A: 

Have you considered unit testing frameworks such as JUnit and TestNG? They are very powerful and allow you to write test cases to test your API methods. You can provide specific inputs to a method and see if it returns the desired result, for example.

Jon
+1  A: 

Actually what you're looking for is a white-box testing solution.

For Java you can use JCrasher, For C# you can use Pex

They analyze your source code and try to "break" your application by sending as many crazy values for your parameters to your methods and object constructors as possible. They then generate unit tests so that you can use regression testing in the future.

Example:

void MyMethod (integer s)

A white-box testing solution would send in all sorts of crazy values, some random some pre-determined. One example is it will send in a null value if it's nullable in your chosen language. It will also send in the Maximum and Minimum integer values to see what happens there.

masenkablast
To be precise, Pex crafts inputs in order to generate maximum coverage. To do so, it does not generate random values but rather uses a technique called 'dynamic symbolic execution'.
Peli
+1 Absolutely correct
masenkablast
A: 

If your API is well specified, standard unit testing with JUnit that treats the API as a black box is typically enough at the function level to ensure that the API works correctly.

If you can, also unit test common method combinations and micro-patterns (e.g., open-execute-close) and likely violations of these. Providing potential users with samples of patterns and combinations

In my experience, the vast majority of errors that involve the use of APIs are in how your clients understand it. Things like combinations of calls are usually on the path to failure.

In addition, pay close attention to documentation. Be aware that complete and accurate specification of each function in the JavaDocs may actually make your API documentation less useful to potential callers.

Uri