Click here to Skip to main content
16,023,124 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I have already some integration tests for java code, I'm wondering if there is any way to detect the source and the target of each integration test, for example if we have two components A and B, when component A calls component B we should have an integration test to test these two components together, and when component B calls component A we should have another integration test, my question is from the test cases can we decide which component is the caller and which was the callee depends on the integration test code automatically, by using tool or specific libraries.
Posted
Comments
Nagy Vilmos 12-Oct-11 3:28am    
I'm not sure what it is you are trying to get at.
Is your question about detecting call paths or about ensuring coverage by all test cases?
medoded2009 17-Oct-11 16:03pm    
Dear Nagy,
exactly I want to detect the call path automatically, who called whom in each integration test.
A called B or B called A in the integration test for A and B, it's easy to detect it manually by looking at the test code but I'm wondering if there anything in literature helps to make it automatically.

Thanks Nagy for quick response

1 solution

AFAIK there is no way to externally view the call stack. Once inside a method you can get the call stack thus:
Java
StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();

I am not sure this will help you as you wish to check that all methods are called.

I would suggest a two pronged approach to testing; this is something I have employed and works.

Firstly unit test. This should be 'white box', the tester knows what is being called and creates tests to cover all the paths; or as many as are practical.

Secondly integration test. This is a 'black box' test, validate that the software is delivering what is expected. This will often be from the UI point of view and can be automated for reliable reproduction.

In addition to this, if the application goes through several releases, is regression testing. Ensure the application still do what it was doing prior to any changes.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900