Web Services Testing

I am working on a Java project, which is divided into a web project and a background project. The web interface accesses background content through web service calls.

There is one class in the web project that makes all the calls to web services, and I would like to add testing around this class. I want to do unit testing, not functional testing, so I don’t want the web service to actually run the tests. If this class simply passed calls to the background code, I could refuse testing, but caching is happening at the moment, so I want to check that it works correctly.

When creating the jax-ws web service, wsgen creates an interface that uses the interface. I used this generated interface to create a fake object for testing. This works very well, but there are problems with this approach.

Currently, I am the only one in my team who conducts unit testing, and this is the only one that supports test code. I would like to be able to create test code when the rest of the code is built, but if someone else introduces a new method into one of the web services classes, then the interface will have a new method on it and my fake object will not implement it and therefore it will be broken.

Website and reverse code projects are independent of each other, and I do not want to introduce a dependency between them. Thus, introducing an interface on top of the web service endpoint does not seem plausible, because if I put it at the end, my web code must reference it, and if I put it on the interface, my back-end code must reference it . I also cannot expand the endpoint, as this will also lead to dependency between projects.

I am not familiar with how web services work, and how classes are generated for a web project in order to be able to reference them. So, I do not know how to create an interface in the back that will be available to me in a web project.

So my question is: how can I access the interface for my front-end project without introducing the project dependency (in the path of building Eclipse)? Or is there another, better way to trick the internal web service I'm calling?

+4
source share
1 answer

Firstly, I pulled out the caching code in the device under test, which is not directly dependent on web service calls.

As for web services, I find it useful to use both functional tests that use web services and other tests that mock web services. Functional tests can help you find cross-cases that might lose your layouts.

For example, I use Axis2 and create stubs from WSDL. For layouts, I simply implement or extend the generated stubs. In our case, a real web service is implemented by an external organization. Examining their web service using functional research tests revealed some exceptions that needed to be handled, which were not obvious, simply by examining the generated stubs. I used this information to make fun of these cases.

+2
source

Source: https://habr.com/ru/post/1386760/


All Articles