I wanted to share with you my way of testing web services.
The principle is this:
1. Create a maven project.
2. We configure it so that with each launch the following is performed:
2.1. WSDL service description was loaded by reference
2.2. client code was generated based on WSDL description
2.3. the assertion code was generated for the classes involved in the tests, including those that were generated in the previous step
3. We write tests.
4. Add the project to jenkins, which runs the testing itself.
We will need the following tools: Java, maven, AssertJ, TestNG.
AssertJ is an interesting framework that, among other things, is able to generate events for specific classes. This allows you to write tests like this:
//Выполняем запрос к сервису
CheckTextRequest r = new CheckTextRequest();
r.setText("Фраза с ошибкой в слове БРОШУРА");
CheckTextResponse resp = port.checkText(r);
SpellError sError = resp.getSpellResult().getError().get(0);
//проверяем ответ c помощью сгенерированных асертов
soft.assertThat(sError )
.as("Проверка SpellError")
.hasCode(1)
.hasCol(24)
.hasLen(7)
.hasPos(24)
.hasRow(0)
.hasWord("БРОШУРА555")
.hasOnlyS("БРОШЮРА ошибка");
And, in case of an error, the result will be like this:
The following assertion failed:
1) [Проверка SpellError]
Expecting word of:
to be:
<БРОШУРА555>
but was:
<БРОШУРА>
at org.assertj.SoftAssertions.assertAll(SoftAssertions.java:32)
at ru.x_noname.test.SOAPTest$Listener.afterInvocation(SOAPTest.java:69)
...