Add TestNG support for spring-cloud-contract-verifier (#1101) (#1135)

fixes #1101
This commit is contained in:
janeisklar
2019-07-12 12:17:12 +02:00
committed by Marcin Grzejszczak
parent 82be516441
commit c55031e094
21 changed files with 511 additions and 22 deletions

View File

@@ -154,6 +154,9 @@ class MethodBodyBuilderSpec extends Specification implements WireMockStubVerifie
"webclient" | {
properties.testMode = TestMode.WEBTESTCLIENT
}
"testNG" | {
properties.testFramework = TestFramework.TESTNG
}
}
@Issue('#588')
@@ -196,6 +199,9 @@ class MethodBodyBuilderSpec extends Specification implements WireMockStubVerifie
"webclient" | {
properties.testMode = TestMode.WEBTESTCLIENT
}
"testNG" | {
properties.testFramework = TestFramework.TESTNG
}
}
@Issue('#521')
@@ -241,6 +247,9 @@ class MethodBodyBuilderSpec extends Specification implements WireMockStubVerifie
"webclient" | {
properties.testMode = TestMode.WEBTESTCLIENT
}
"testNG" | {
properties.testFramework = TestFramework.TESTNG
}
}
@Issue('#269')
@@ -288,6 +297,9 @@ class MethodBodyBuilderSpec extends Specification implements WireMockStubVerifie
"webclient" | {
properties.testMode = TestMode.WEBTESTCLIENT
}
"testNG" | {
properties.testFramework = TestFramework.TESTNG
}
}
@Issue('#289')
@@ -333,6 +345,9 @@ class MethodBodyBuilderSpec extends Specification implements WireMockStubVerifie
"webclient" | {
properties.testMode = TestMode.WEBTESTCLIENT
}
"testNG" | {
properties.testFramework = TestFramework.TESTNG
}
}
@Issue('#313')
@@ -375,6 +390,9 @@ class MethodBodyBuilderSpec extends Specification implements WireMockStubVerifie
"webclient" | {
properties.testMode = TestMode.WEBTESTCLIENT
}
"testNG" | {
properties.testFramework = TestFramework.TESTNG
}
}
@Issue('#318')
@@ -423,6 +441,13 @@ class MethodBodyBuilderSpec extends Specification implements WireMockStubVerifie
contains('assertThat(response.header("Content-Length")).isEqualTo(4);') && testBody.
contains('assertThat(response.header("Content-Type")).matches("application/pdf.*");')
}
"mockmvc-testng" | {
properties.testFramework = TestFramework.TESTNG; properties.testMode = TestMode.MOCKMVC
} | { String testBody ->
testBody.
contains('assertThat(response.header("Content-Length")).isEqualTo(4);') && testBody.
contains('assertThat(response.header("Content-Type")).matches("application/pdf.*");')
}
"jaxrs-spock" | {
properties.testFramework = TestFramework.SPOCK; properties.testMode = TestMode.JAXRSCLIENT
} | { String testBody ->
@@ -491,6 +516,9 @@ class MethodBodyBuilderSpec extends Specification implements WireMockStubVerifie
"webclient" | {
properties.testMode = TestMode.WEBTESTCLIENT
}
"testNG" | {
properties.testFramework = TestFramework.TESTNG
}
}
@Issue('#424')
@@ -535,6 +563,9 @@ class MethodBodyBuilderSpec extends Specification implements WireMockStubVerifie
"webclient" | {
properties.testMode = TestMode.WEBTESTCLIENT
}
"testNG" | {
properties.testFramework = TestFramework.TESTNG
}
}
@Issue('#458')
@@ -571,6 +602,11 @@ class MethodBodyBuilderSpec extends Specification implements WireMockStubVerifie
} | { String string ->
string.contains('assertThat(responseBody).isEqualTo("My name");')
}
"mockmvc-testng" | {
properties.testFramework = TestFramework.TESTNG; properties.testMode = TestMode.MOCKMVC
} | { String string ->
string.contains('assertThat(responseBody).isEqualTo("My name");')
}
"jaxrs-spock" | {
properties.testFramework = TestFramework.SPOCK; properties.testMode = TestMode.JAXRSCLIENT
} | { String string ->
@@ -636,6 +672,9 @@ class MethodBodyBuilderSpec extends Specification implements WireMockStubVerifie
"webclient" | {
properties.testMode = TestMode.WEBTESTCLIENT
}
"testNG" | {
properties.testFramework = TestFramework.TESTNG
}
}
@Issue('#702')
@@ -701,6 +740,9 @@ class MethodBodyBuilderSpec extends Specification implements WireMockStubVerifie
"webclient" | {
properties.testMode = TestMode.WEBTESTCLIENT
}
"testNG" | {
properties.testFramework = TestFramework.TESTNG
}
}
@Issue('#465')
@@ -753,6 +795,9 @@ class MethodBodyBuilderSpec extends Specification implements WireMockStubVerifie
"webclient" | {
properties.testMode = TestMode.WEBTESTCLIENT
}
"testNG" | {
properties.testFramework = TestFramework.TESTNG
}
}
def 'should use fixed delay milliseconds in the generated test [#methodBuilderName]'() {
@@ -829,6 +874,9 @@ class MethodBodyBuilderSpec extends Specification implements WireMockStubVerifie
"webclient" | {
properties.testMode = TestMode.WEBTESTCLIENT
}
"testNG" | {
properties.testFramework = TestFramework.TESTNG
}
}
@Issue('#578')
@@ -893,6 +941,9 @@ class MethodBodyBuilderSpec extends Specification implements WireMockStubVerifie
"webclient" | {
properties.testMode = TestMode.WEBTESTCLIENT
}
"testNG" | {
properties.testFramework = TestFramework.TESTNG
}
}
@Issue('#493')
@@ -953,6 +1004,9 @@ class MethodBodyBuilderSpec extends Specification implements WireMockStubVerifie
"webclient" | {
properties.testMode = TestMode.WEBTESTCLIENT
}
"testNG" | {
properties.testFramework = TestFramework.TESTNG
}
}
def 'should work with files that have new lines [#methodBuilderName]'() {
@@ -999,6 +1053,9 @@ class MethodBodyBuilderSpec extends Specification implements WireMockStubVerifie
"webclient" | {
properties.testMode = TestMode.WEBTESTCLIENT
}
"testNG" | {
properties.testFramework = TestFramework.TESTNG
}
}
@Issue('#509')
@@ -1075,6 +1132,9 @@ class MethodBodyBuilderSpec extends Specification implements WireMockStubVerifie
"webclient" | {
properties.testMode = TestMode.WEBTESTCLIENT
}
"testNG" | {
properties.testFramework = TestFramework.TESTNG
}
}
def 'should not escape a regex pattern when matching raw body value [#methodBuilderName]'() {
@@ -1114,6 +1174,9 @@ class MethodBodyBuilderSpec extends Specification implements WireMockStubVerifie
"webclient" | {
properties.testMode = TestMode.WEBTESTCLIENT
}
"testNG" | {
properties.testFramework = TestFramework.TESTNG
}
}
@Issue("#664")
@@ -1145,6 +1208,13 @@ class MethodBodyBuilderSpec extends Specification implements WireMockStubVerifie
} | { String string ->
string.contains('assertThat(response.getBody().asByteArray()).isEqualTo(fileToBytes(this, "worksWithPdf_response_response.pdf"));')
}
"mockmvc-testng" | {
properties.testFramework = TestFramework.TESTNG; properties.testMode = TestMode.MOCKMVC
} | { String string ->
string.contains('.body(fileToBytes(this, "worksWithPdf_request_request.pdf"));')
} | { String string ->
string.contains('assertThat(response.getBody().asByteArray()).isEqualTo(fileToBytes(this, "worksWithPdf_response_response.pdf"));')
}
"jaxrs-spock" | {
properties.testFramework = TestFramework.SPOCK; properties.testMode = TestMode.JAXRSCLIENT
} | { String string ->
@@ -1245,6 +1315,9 @@ class MethodBodyBuilderSpec extends Specification implements WireMockStubVerifie
"webclient" | {
properties.testMode = TestMode.WEBTESTCLIENT
}
"testNG" | {
properties.testFramework = TestFramework.TESTNG
}
}
@Issue("#852")
@@ -1291,6 +1364,9 @@ class MethodBodyBuilderSpec extends Specification implements WireMockStubVerifie
"jaxrs" | {
properties.testFramework = TestFramework.JUNIT; properties.testMode = TestMode.JAXRSCLIENT
}
"testNG" | {
properties.testFramework = TestFramework.TESTNG
}
}
@Issue("#844")
@@ -1348,6 +1424,9 @@ class MethodBodyBuilderSpec extends Specification implements WireMockStubVerifie
"jaxrs" | {
properties.testFramework = TestFramework.JUNIT; properties.testMode = TestMode.JAXRSCLIENT
}
"testNG" | {
properties.testFramework = TestFramework.TESTNG
}
}
@Issue("#652")
@@ -1448,6 +1527,9 @@ class MethodBodyBuilderSpec extends Specification implements WireMockStubVerifie
"jaxrs" | {
properties.testFramework = TestFramework.JUNIT; properties.testMode = TestMode.JAXRSCLIENT
}
"testNG" | {
properties.testFramework = TestFramework.TESTNG
}
}
@Issue("#727")
@@ -1497,6 +1579,9 @@ class MethodBodyBuilderSpec extends Specification implements WireMockStubVerifie
"jaxrs" | {
properties.testFramework = TestFramework.JUNIT; properties.testMode = TestMode.JAXRSCLIENT
}
"testNG" | {
properties.testFramework = TestFramework.TESTNG
}
}
@Issue("#892")
@@ -1543,6 +1628,13 @@ class MethodBodyBuilderSpec extends Specification implements WireMockStubVerifie
contains('''assertThat(response.header("Content-Type")).matches("^\\\\s*\\\\S[\\\\S\\\\s]*")''') && testContent.
contains('''assertThat(response.header("Content-Length")).matches("([1-9]\\\\d*)")'''); return true
}
"mockmvc-testng" | {
properties.testFramework = TestFramework.TESTNG; properties.testMode = TestMode.MOCKMVC
} | { String testContent ->
assert testContent.
contains('''assertThat(response.header("Content-Type")).matches("^\\\\s*\\\\S[\\\\S\\\\s]*")''') && testContent.
contains('''assertThat(response.header("Content-Length")).matches("([1-9]\\\\d*)")'''); return true
}
"jaxrs-spock" | {
properties.testFramework = TestFramework.SPOCK; properties.testMode = TestMode.JAXRSCLIENT
} | { String testContent ->
@@ -1599,6 +1691,9 @@ class MethodBodyBuilderSpec extends Specification implements WireMockStubVerifie
"jaxrs" | {
properties.testFramework = TestFramework.JUNIT; properties.testMode = TestMode.JAXRSCLIENT
}
"testNG" | {
properties.testFramework = TestFramework.TESTNG
}
}
@Issue("#1052")
@@ -1656,6 +1751,9 @@ response:
"jaxrs" | {
properties.testFramework = TestFramework.JUNIT; properties.testMode = TestMode.JAXRSCLIENT
}
"testNG" | {
properties.testFramework = TestFramework.TESTNG
}
}
@Issue("#1049")
@@ -1695,6 +1793,9 @@ response:
"jaxrs" | {
properties.testFramework = TestFramework.JUNIT; properties.testMode = TestMode.JAXRSCLIENT
}
"testNG" | {
properties.testFramework = TestFramework.TESTNG
}
}
def 'should resolve headers from request correctly'() {
@@ -1744,7 +1845,9 @@ response:
"jaxrs" | {
properties.testFramework = TestFramework.JUNIT; properties.testMode = TestMode.JAXRSCLIENT
}
"testNG" | {
properties.testFramework = TestFramework.TESTNG
}
}
}

View File

@@ -245,6 +245,7 @@ class MockMvcMethodBodyBuilderWithMatchersSpec extends Specification implements
where:
methodBuilderName | methodBuilder | rootElement
"spock" | { properties.testFramework = TestFramework.SPOCK } | '\\$'
"testng" | { properties.testFramework = TestFramework.TESTNG }| '$'
"mockmvc" | { properties.testMode = TestMode.MOCKMVC } | '$'
"jaxrs-spock" | {
properties.testFramework = TestFramework.SPOCK; properties.testMode = TestMode.JAXRSCLIENT
@@ -320,6 +321,7 @@ class MockMvcMethodBodyBuilderWithMatchersSpec extends Specification implements
where:
methodBuilderName | methodBuilder | rootElement
"spock" | { properties.testFramework = TestFramework.SPOCK } | '\\$'
"testng" | { properties.testFramework = TestFramework.TESTNG }| '$'
"mockmvc" | { properties.testMode = TestMode.MOCKMVC } | '$'
"jaxrs-spock" | {
properties.testFramework = TestFramework.SPOCK; properties.testMode = TestMode.JAXRSCLIENT
@@ -380,6 +382,7 @@ class MockMvcMethodBodyBuilderWithMatchersSpec extends Specification implements
where:
methodBuilderName | methodBuilder | rootElement
"spock" | { properties.testFramework = TestFramework.SPOCK } | '\\$'
"testng" | { properties.testFramework = TestFramework.TESTNG }| '$'
"mockmvc" | { properties.testMode = TestMode.MOCKMVC } | '$'
"jaxrs-spock" | {
properties.testFramework = TestFramework.SPOCK; properties.testMode = TestMode.JAXRSCLIENT
@@ -420,6 +423,7 @@ class MockMvcMethodBodyBuilderWithMatchersSpec extends Specification implements
where:
methodBuilderName | methodBuilder | rootElement
"spock" | { properties.testFramework = TestFramework.SPOCK } | '\\$'
"testng" | { properties.testFramework = TestFramework.TESTNG }| '$'
"mockmvc" | { properties.testMode = TestMode.MOCKMVC } | '$'
"jaxrs-spock" | {
properties.testFramework = TestFramework.SPOCK; properties.testMode = TestMode.JAXRSCLIENT
@@ -461,6 +465,7 @@ class MockMvcMethodBodyBuilderWithMatchersSpec extends Specification implements
where:
methodBuilderName | methodBuilder | rootElement
"spock" | { properties.testFramework = TestFramework.SPOCK } | '\\$'
"testng" | { properties.testFramework = TestFramework.TESTNG }| '$'
"mockmvc" | { properties.testMode = TestMode.MOCKMVC } | '$'
"jaxrs-spock" | {
properties.testFramework = TestFramework.SPOCK; properties.testMode = TestMode.JAXRSCLIENT
@@ -504,6 +509,7 @@ class MockMvcMethodBodyBuilderWithMatchersSpec extends Specification implements
where:
methodBuilderName | methodBuilder | rootElement
"spock" | { properties.testFramework = TestFramework.SPOCK } | '\\$'
"testng" | { properties.testFramework = TestFramework.TESTNG }| '$'
"mockmvc" | { properties.testMode = TestMode.MOCKMVC } | '$'
"jaxrs-spock" | {
properties.testFramework = TestFramework.SPOCK; properties.testMode = TestMode.JAXRSCLIENT
@@ -555,6 +561,7 @@ class MockMvcMethodBodyBuilderWithMatchersSpec extends Specification implements
where:
methodBuilderName | methodBuilder
"spock" | { properties.testFramework = TestFramework.SPOCK }
"testng" | { properties.testFramework = TestFramework.TESTNG }
"mockmvc" | { properties.testMode = TestMode.MOCKMVC }
"jaxrs-spock" | {
properties.testFramework = TestFramework.SPOCK; properties.testMode = TestMode.JAXRSCLIENT
@@ -602,6 +609,7 @@ class MockMvcMethodBodyBuilderWithMatchersSpec extends Specification implements
where:
methodBuilderName | methodBuilder
"spock" | { properties.testFramework = TestFramework.SPOCK }
"testng" | { properties.testFramework = TestFramework.TESTNG }
"mockmvc" | { properties.testMode = TestMode.MOCKMVC }
"jaxrs-spock" | {
properties.testFramework = TestFramework.SPOCK; properties.testMode = TestMode.JAXRSCLIENT

View File

@@ -32,6 +32,7 @@ import org.springframework.util.StringUtils
import static org.springframework.cloud.contract.verifier.config.TestFramework.JUNIT
import static org.springframework.cloud.contract.verifier.config.TestFramework.JUNIT5
import static org.springframework.cloud.contract.verifier.config.TestFramework.SPOCK
import static org.springframework.cloud.contract.verifier.config.TestFramework.TESTNG
import static org.springframework.cloud.contract.verifier.config.TestMode.EXPLICIT
import static org.springframework.cloud.contract.verifier.config.TestMode.JAXRSCLIENT
import static org.springframework.cloud.contract.verifier.config.TestMode.MOCKMVC
@@ -94,6 +95,32 @@ class SingleTestGeneratorSpec extends Specification {
'import static com.toomuchcoding.jsonassert.JsonAssertion.assertThatJson;', 'import static io.restassured.RestAssured.*;',
'@Test', '@Disabled', 'import io.restassured.specification.RequestSpecification;',
'import io.restassured.response.Response;', 'import static org.springframework.cloud.contract.verifier.assertion.SpringCloudContractAssertions.assertThat']
private static
final List<String> mockMvcTestNGRestAssured2ClassStrings = ['import com.jayway.jsonpath.DocumentContext;', 'import com.jayway.jsonpath.JsonPath;',
'import org.testng.annotations.Test;',
'import static com.toomuchcoding.jsonassert.JsonAssertion.assertThatJson;', 'import static com.jayway.restassured.module.mockmvc.RestAssuredMockMvc.*;',
'@Test', 'import com.jayway.restassured.module.mockmvc.specification.MockMvcRequestSpecification;',
'import com.jayway.restassured.response.ResponseOptions;', 'import static org.springframework.cloud.contract.verifier.assertion.SpringCloudContractAssertions.assertThat']
private static
final List<String> mockMvcTestNGRestAssured3ClassStrings = ['import com.jayway.jsonpath.DocumentContext;', 'import com.jayway.jsonpath.JsonPath;',
'import org.testng.annotations.Test;',
'import static com.toomuchcoding.jsonassert.JsonAssertion.assertThatJson;', 'import static io.restassured.module.mockmvc.RestAssuredMockMvc.*;',
'@Test', 'import io.restassured.module.mockmvc.specification.MockMvcRequestSpecification;',
'import io.restassured.response.ResponseOptions;', 'import static org.springframework.cloud.contract.verifier.assertion.SpringCloudContractAssertions.assertThat']
private static
final List<String> explicitTestNGRestAssured2ClassStrings = ['import com.jayway.jsonpath.DocumentContext;', 'import com.jayway.jsonpath.JsonPath;',
'org.testng.annotations.Test;',
'import static com.toomuchcoding.jsonassert.JsonAssertion.assertThatJson;', 'import static com.jayway.restassured.RestAssured.*;',
'@Test', 'import com.jayway.restassured.specification.RequestSpecification;',
'import com.jayway.restassured.response.Response;', 'import static org.springframework.cloud.contract.verifier.assertion.SpringCloudContractAssertions.assertThat']
private static
final List<String> explicitTestNGRestAssured3ClassStrings = ['import com.jayway.jsonpath.DocumentContext;', 'import com.jayway.jsonpath.JsonPath;',
'import org.testng.annotations.Test;',
'import static com.toomuchcoding.jsonassert.JsonAssertion.assertThatJson;', 'import static io.restassured.RestAssured.*;',
'@Test', 'import io.restassured.specification.RequestSpecification;',
'import io.restassured.response.Response;', 'import static org.springframework.cloud.contract.verifier.assertion.SpringCloudContractAssertions.assertThat']
private static final List<String> spockClassRestAssured2Strings = ['import com.jayway.jsonpath.DocumentContext', 'import com.jayway.jsonpath.JsonPath',
@@ -188,6 +215,8 @@ class SingleTestGeneratorSpec extends Specification {
JUNIT | 2 | EXPLICIT | explicitJUnitRestAssured3ClassStrings | JAVA_ASSERTER
JUNIT5 | null | MOCKMVC | mockMvcJUnit5RestAssured3ClassStrings | JAVA_ASSERTER
JUNIT5 | null | EXPLICIT | explicitJUnit5RestAssured3ClassStrings | JAVA_ASSERTER
TESTNG | null | MOCKMVC | mockMvcTestNGRestAssured3ClassStrings | JAVA_ASSERTER
TESTNG | null | EXPLICIT | explicitTestNGRestAssured3ClassStrings | JAVA_ASSERTER
SPOCK | 2 | MOCKMVC | spockClassRestAssured3Strings | GROOVY_ASSERTER
SPOCK | 2 | EXPLICIT | explicitSpockRestAssured3ClassStrings | GROOVY_ASSERTER
}
@@ -218,6 +247,8 @@ class SingleTestGeneratorSpec extends Specification {
JUNIT | EXPLICIT | JAVA_ASSERTER | 'ContractsTest.java'
JUNIT5 | MOCKMVC | JAVA_ASSERTER | 'ContractsTest.java'
JUNIT5 | EXPLICIT | JAVA_ASSERTER | 'ContractsTest.java'
TESTNG | MOCKMVC | JAVA_ASSERTER | 'ContractsTest.java'
TESTNG | EXPLICIT | JAVA_ASSERTER | 'ContractsTest.java'
SPOCK | MOCKMVC | GROOVY_ASSERTER | 'ContractsSpec.groovy'
SPOCK | EXPLICIT | GROOVY_ASSERTER | 'ContractsSpec.groovy'
}
@@ -291,6 +322,8 @@ class SingleTestGeneratorSpec extends Specification {
JUNIT | EXPLICIT | explicitJUnitRestAssured3ClassStrings | JAVA_ASSERTER | { String test -> StringUtils.countOccurrencesOf(test, '\t\t\tMockMvcRequestSpecification') == 2 }
JUNIT5 | MOCKMVC | mockMvcJUnit5RestAssured3ClassStrings | JAVA_ASSERTER | { String test -> StringUtils.countOccurrencesOf(test, '\t\t\tMockMvcRequestSpecification') == 2 }
JUNIT5 | EXPLICIT | explicitJUnit5RestAssured3ClassStrings | JAVA_ASSERTER | { String test -> StringUtils.countOccurrencesOf(test, '\t\t\tMockMvcRequestSpecification') == 2 }
TESTNG | MOCKMVC | mockMvcTestNGRestAssured3ClassStrings | JAVA_ASSERTER | { String test -> StringUtils.countOccurrencesOf(test, '\t\t\tMockMvcRequestSpecification') == 2 }
TESTNG | EXPLICIT | explicitTestNGRestAssured3ClassStrings | JAVA_ASSERTER | { String test -> StringUtils.countOccurrencesOf(test, '\t\t\tMockMvcRequestSpecification') == 2 }
SPOCK | MOCKMVC | spockClassRestAssured3Strings | GROOVY_ASSERTER | { String test -> StringUtils.countOccurrencesOf(test, '\t\t\tMockMvcRequestSpecification') == 2 }
SPOCK | EXPLICIT | explicitSpockRestAssured2ClassStrings | GROOVY_ASSERTER | { String test -> StringUtils.countOccurrencesOf(test, '\t\t\tMockMvcRequestSpecification request') == 2 }
}
@@ -317,6 +350,7 @@ class SingleTestGeneratorSpec extends Specification {
testFramework | classStrings | asserter
JUNIT | ['import static javax.ws.rs.client.Entity.*', 'import javax.ws.rs.core.Response'] | JAVA_JAXRS_ASSERTER
JUNIT5 | ['import static javax.ws.rs.client.Entity.*', 'import javax.ws.rs.core.Response'] | JAVA_JAXRS_ASSERTER
TESTNG | ['import static javax.ws.rs.client.Entity.*', 'import javax.ws.rs.core.Response'] | JAVA_JAXRS_ASSERTER
SPOCK | ['import static javax.ws.rs.client.Entity.*'] | GROOVY_ASSERTER
}
@@ -364,6 +398,7 @@ class SingleTestGeneratorSpec extends Specification {
testFramework | order | classStrings | asserter
JUNIT | 2 | mockMvcJUnitRestAssured3ClassStrings | JAVA_ASSERTER
JUNIT5 | null | mockMvcJUnit5RestAssured3ClassStrings | JAVA_ASSERTER
TESTNG | null | mockMvcTestNGRestAssured3ClassStrings | JAVA_ASSERTER
SPOCK | 2 | spockClassRestAssured3Strings | GROOVY_ASSERTER
}
@@ -403,10 +438,26 @@ class SingleTestGeneratorSpec extends Specification {
asserter(clazz)
where:
testFramework | order | classStrings | ignoreAnnotation | asserter
JUNIT | 2 | mockMvcJUnitRestAssured3ClassStrings | '@Ignore' | JAVA_ASSERTER
JUNIT5 | null | mockMvcJUnit5RestAssured3ClassStrings | '@Disabled' | JAVA_ASSERTER
SPOCK | 2 | spockClassRestAssured3Strings | '@Ignore' | GROOVY_ASSERTER
testFramework | order | classStrings | ignoreAnnotation | asserter
JUNIT | 2 | mockMvcJUnitRestAssured3ClassStrings | '@Ignore' | JAVA_ASSERTER
JUNIT5 | null | mockMvcJUnit5RestAssured3ClassStrings | '@Disabled' | JAVA_ASSERTER
TESTNG | null | mockMvcTestNGRestAssured3ClassStrings | '@Test(enabled = false)' | JAVA_ASSERTER
SPOCK | 2 | spockClassRestAssured3Strings | '@Ignore' | GROOVY_ASSERTER
}
def 'should not allow the usage of ignore annotations for TestNG '() {
given:
TestFramework testNG = TESTNG
when:
testNG.getIgnoreClass()
then:
thrown UnsupportedOperationException
when:
testNG.getIgnoreAnnotation()
then:
thrown UnsupportedOperationException
}
@Issue('#117')
@@ -490,7 +541,7 @@ class SingleTestGeneratorSpec extends Specification {
then:
clazz.contains('validate_mySuperMethod()')
where:
testFramework << [JUNIT, JUNIT5, SPOCK]
testFramework << [JUNIT, JUNIT5, TESTNG, SPOCK]
}
def "should pick the contract's name as the test method when there are multiple contracts for #testFramework"() {
@@ -523,7 +574,7 @@ class SingleTestGeneratorSpec extends Specification {
clazz.contains('validate_shouldHaveIndex1()')
clazz.contains('validate_shouldHaveIndex2()')
where:
testFramework << [JUNIT, JUNIT5, SPOCK]
testFramework << [JUNIT, JUNIT5, TESTNG, SPOCK]
}
def 'should generate the test method when there are multiple contracts without name field for #testFramework'() {
@@ -555,7 +606,7 @@ class SingleTestGeneratorSpec extends Specification {
clazz.contains('_0() throws Exception')
clazz.contains('_1() throws Exception')
where:
testFramework << [JUNIT, JUNIT5, SPOCK]
testFramework << [JUNIT, JUNIT5, TESTNG, SPOCK]
}
@Issue('#359')
@@ -581,7 +632,7 @@ class SingleTestGeneratorSpec extends Specification {
test.contains('readFromFile_request_request.json')
test.contains('RESPONSE')
where:
testFramework << [JUNIT, JUNIT5, SPOCK]
testFramework << [JUNIT, JUNIT5, TESTNG, SPOCK]
}
@Issue('#260')
@@ -606,7 +657,7 @@ class SingleTestGeneratorSpec extends Specification {
test.contains('readFromFile_request_request.json')
test.contains('RESPONSE')
where:
testFramework << [JUNIT, JUNIT5, SPOCK]
testFramework << [JUNIT, JUNIT5, TESTNG, SPOCK]
}
@Issue('#260')
@@ -631,7 +682,7 @@ class SingleTestGeneratorSpec extends Specification {
test.contains('readFromFile_request_request.json')
test.contains('RESPONSE')
where:
testFramework << [JUNIT, JUNIT5, SPOCK]
testFramework << [JUNIT, JUNIT5, TESTNG, SPOCK]
}
@Issue('#260')
@@ -656,7 +707,7 @@ class SingleTestGeneratorSpec extends Specification {
test.contains('readFromFile_request_request.json')
test.contains('RESPONSE')
where:
testFramework << [JUNIT, JUNIT5, SPOCK]
testFramework << [JUNIT, JUNIT5, TESTNG, SPOCK]
}
@Issue('#260')
@@ -680,7 +731,7 @@ class SingleTestGeneratorSpec extends Specification {
test.contains('readFromFile_request_request.json')
test.contains('RESPONSE')
where:
testFramework << [JUNIT, JUNIT5, SPOCK]
testFramework << [JUNIT, JUNIT5, TESTNG, SPOCK]
}
def 'should throw exception in JUnit5 when contract belongs to scenario'() {

View File

@@ -214,6 +214,7 @@ class SpringTestMethodBodyBuildersSpec extends Specification implements WireMock
where:
methodBuilderName | methodBuilder
"spock" | { properties.testFramework = TestFramework.SPOCK }
"testng" | { properties.testFramework = TestFramework.TESTNG }
"mockmvc" | { properties.testMode = TestMode.MOCKMVC }
"webclient" | { properties.testMode = TestMode.WEBTESTCLIENT }
}
@@ -277,6 +278,7 @@ class SpringTestMethodBodyBuildersSpec extends Specification implements WireMock
where:
methodBuilderName | methodBuilder
"spock" | { properties.testFramework = TestFramework.SPOCK }
"testng" | { properties.testFramework = TestFramework.TESTNG }
"mockmvc" | { properties.testMode = TestMode.MOCKMVC }
"webclient" | { properties.testMode = TestMode.WEBTESTCLIENT }
}
@@ -314,6 +316,7 @@ class SpringTestMethodBodyBuildersSpec extends Specification implements WireMock
where:
methodBuilderName | methodBuilder
"spock" | { properties.testFramework = TestFramework.SPOCK }
"testng" | { properties.testFramework = TestFramework.TESTNG }
"mockmvc" | { properties.testMode = TestMode.MOCKMVC }
"webclient" | { properties.testMode = TestMode.WEBTESTCLIENT }
}
@@ -354,6 +357,7 @@ class SpringTestMethodBodyBuildersSpec extends Specification implements WireMock
where:
methodBuilderName | methodBuilder
"spock" | { properties.testFramework = TestFramework.SPOCK }
"testng" | { properties.testFramework = TestFramework.TESTNG }
"mockmvc" | { properties.testMode = TestMode.MOCKMVC }
"webclient" | { properties.testMode = TestMode.WEBTESTCLIENT }
}
@@ -388,6 +392,9 @@ class SpringTestMethodBodyBuildersSpec extends Specification implements WireMock
"mockmvc" | {
properties.testMode = TestMode.MOCKMVC
} | '.body("{\\"items\\":[\\"HOP\\"]}")'
"testng" | {
properties.testFramework = TestFramework.TESTNG
} | '.body("{\\"items\\":[\\"HOP\\"]}")'
"webclient" | {
properties.testMode = TestMode.WEBTESTCLIENT
} | '.body("{\\"items\\":[\\"HOP\\"]}")'
@@ -420,6 +427,7 @@ class SpringTestMethodBodyBuildersSpec extends Specification implements WireMock
where:
methodBuilderName | methodBuilder | bodyString
"spock" | { properties.testFramework = TestFramework.SPOCK } | """.body('''property1=VAL1''')"""
"testng" | { properties.testFramework = TestFramework.TESTNG }| '.body("property1=VAL1")'
"mockmvc" | { properties.testMode = TestMode.MOCKMVC } | '.body("property1=VAL1")'
"webclient" | { properties.testMode = TestMode.WEBTESTCLIENT } | '.body("property1=VAL1")'
}
@@ -455,6 +463,7 @@ class SpringTestMethodBodyBuildersSpec extends Specification implements WireMock
where:
methodBuilderName | methodBuilder
"spock" | { properties.testFramework = TestFramework.SPOCK }
"testng" | { properties.testFramework = TestFramework.TESTNG }
"mockmvc" | { properties.testMode = TestMode.MOCKMVC }
"webclient" | { properties.testMode = TestMode.WEBTESTCLIENT }
}
@@ -490,6 +499,7 @@ class SpringTestMethodBodyBuildersSpec extends Specification implements WireMock
where:
methodBuilderName | methodBuilder
"spock" | { properties.testFramework = TestFramework.SPOCK }
"testng" | { properties.testFramework = TestFramework.TESTNG }
"mockmvc" | { properties.testMode = TestMode.MOCKMVC }
"webclient" | { properties.testMode = TestMode.WEBTESTCLIENT }
}
@@ -524,6 +534,7 @@ class SpringTestMethodBodyBuildersSpec extends Specification implements WireMock
where:
methodBuilderName | methodBuilder
"spock" | { properties.testFramework = TestFramework.SPOCK }
"testng" | { properties.testFramework = TestFramework.TESTNG }
"mockmvc" | { properties.testMode = TestMode.MOCKMVC }
"webclient" | { properties.testMode = TestMode.WEBTESTCLIENT }
}
@@ -558,6 +569,7 @@ class SpringTestMethodBodyBuildersSpec extends Specification implements WireMock
where:
methodBuilderName | methodBuilder
"spock" | { properties.testFramework = TestFramework.SPOCK }
"testng" | { properties.testFramework = TestFramework.TESTNG }
"mockmvc" | { properties.testMode = TestMode.MOCKMVC }
"webclient" | { properties.testMode = TestMode.WEBTESTCLIENT }
}
@@ -596,6 +608,7 @@ class SpringTestMethodBodyBuildersSpec extends Specification implements WireMock
where:
methodBuilderName | methodBuilder
"spock" | { properties.testFramework = TestFramework.SPOCK }
"testng" | { properties.testFramework = TestFramework.TESTNG }
"mockmvc" | { properties.testMode = TestMode.MOCKMVC }
"webclient" | { properties.testMode = TestMode.WEBTESTCLIENT }
}
@@ -630,6 +643,7 @@ class SpringTestMethodBodyBuildersSpec extends Specification implements WireMock
where:
methodBuilderName | methodBuilder
"spock" | { properties.testFramework = TestFramework.SPOCK }
"testng" | { properties.testFramework = TestFramework.TESTNG }
"mockmvc" | { properties.testMode = TestMode.MOCKMVC }
"webclient" | { properties.testMode = TestMode.WEBTESTCLIENT }
}
@@ -664,6 +678,7 @@ class SpringTestMethodBodyBuildersSpec extends Specification implements WireMock
where:
methodBuilderName | methodBuilder
"spock" | { properties.testFramework = TestFramework.SPOCK }
"testng" | { properties.testFramework = TestFramework.TESTNG }
"mockmvc" | { properties.testMode = TestMode.MOCKMVC }
"webclient" | { properties.testMode = TestMode.WEBTESTCLIENT }
}
@@ -720,6 +735,7 @@ class SpringTestMethodBodyBuildersSpec extends Specification implements WireMock
where:
methodBuilderName | methodBuilder
"spock" | { properties.testFramework = TestFramework.SPOCK }
"testng" | { properties.testFramework = TestFramework.TESTNG }
"mockmvc" | { properties.testMode = TestMode.MOCKMVC }
"webclient" | { properties.testMode = TestMode.WEBTESTCLIENT }
}
@@ -777,6 +793,7 @@ class SpringTestMethodBodyBuildersSpec extends Specification implements WireMock
where:
methodBuilderName | methodBuilder
"spock" | { properties.testFramework = TestFramework.SPOCK }
"testng" | { properties.testFramework = TestFramework.TESTNG }
"mockmvc" | { properties.testMode = TestMode.MOCKMVC }
"webclient" | { properties.testMode = TestMode.WEBTESTCLIENT }
}
@@ -805,6 +822,7 @@ class SpringTestMethodBodyBuildersSpec extends Specification implements WireMock
where:
methodBuilderName | methodBuilder | bodyString
"spock" | { properties.testFramework = TestFramework.SPOCK } | ".body('''''')"
"testng" | { properties.testFramework = TestFramework.TESTNG }| '.body("")'
"mockmvc" | { properties.testMode = TestMode.MOCKMVC } | '.body("")'
"webclient" | { properties.testMode = TestMode.WEBTESTCLIENT } | '.body("")'
}
@@ -836,6 +854,9 @@ class SpringTestMethodBodyBuildersSpec extends Specification implements WireMock
"spock" | {
properties.testFramework = TestFramework.SPOCK
} | 'String responseBody = response.body.asString()' | "responseBody == 'test'"
"testng" | {
properties.testFramework = TestFramework.TESTNG
} | 'String responseBody = response.getBody().asString();' | 'assertThat(responseBody).isEqualTo("test");'
"mockmvc" | {
properties.testMode = TestMode.MOCKMVC
} | 'String responseBody = response.getBody().asString();' | 'assertThat(responseBody).isEqualTo("test");'
@@ -880,6 +901,9 @@ class SpringTestMethodBodyBuildersSpec extends Specification implements WireMock
where:
methodBuilderName | methodBuilder | headerEvaluationString
"spock" | { properties.testFramework = TestFramework.SPOCK } | '''response.header("Location") ==~ java.util.regex.Pattern.compile('http://localhost/partners/[0-9]+/users/[0-9]+')'''
"testng" | {
properties.testFramework = TestFramework.TESTNG
} | 'assertThat(response.header("Location")).matches("http://localhost/partners/[0-9]+/users/[0-9]+");'
"mockmvc" | {
properties.testMode = TestMode.MOCKMVC
} | 'assertThat(response.header("Location")).matches("http://localhost/partners/[0-9]+/users/[0-9]+");'
@@ -924,6 +948,9 @@ class SpringTestMethodBodyBuildersSpec extends Specification implements WireMock
where:
methodBuilderName | methodBuilder | headerEvaluationString
"spock" | { properties.testFramework = TestFramework.SPOCK } | '''response.header("Location") ==~ java.util.regex.Pattern.compile('^((http[s]?|ftp):/)/?([^:/\\\\s]+)(:[0-9]{1,5})?/partners/[0-9]+/users/[0-9]+')'''
"testng" | {
properties.testFramework = TestFramework.TESTNG
} | 'assertThat(response.header("Location")).matches("^((http[s]?|ftp):/)/?([^:/\\\\s]+)(:[0-9]{1,5})?/partners/[0-9]+/users/[0-9]+");'
"mockmvc" | {
properties.testMode = TestMode.MOCKMVC
} | 'assertThat(response.header("Location")).matches("^((http[s]?|ftp):/)/?([^:/\\\\s]+)(:[0-9]{1,5})?/partners/[0-9]+/users/[0-9]+");'
@@ -970,6 +997,7 @@ class SpringTestMethodBodyBuildersSpec extends Specification implements WireMock
where:
methodBuilderName | methodBuilder
"spock" | { properties.testFramework = TestFramework.SPOCK }
"testng" | { properties.testFramework = TestFramework.TESTNG }
"mockmvc" | { properties.testMode = TestMode.MOCKMVC }
"webclient" | { properties.testMode = TestMode.WEBTESTCLIENT }
}
@@ -1004,6 +1032,7 @@ class SpringTestMethodBodyBuildersSpec extends Specification implements WireMock
where:
methodBuilderName | methodBuilder
"spock" | { properties.testFramework = TestFramework.SPOCK }
"testng" | { properties.testFramework = TestFramework.TESTNG }
"mockmvc" | { properties.testMode = TestMode.MOCKMVC }
"webclient" | { properties.testMode = TestMode.WEBTESTCLIENT }
}
@@ -1045,6 +1074,7 @@ class SpringTestMethodBodyBuildersSpec extends Specification implements WireMock
where:
methodBuilderName | methodBuilder
"spock" | { properties.testFramework = TestFramework.SPOCK }
"testng" | { properties.testFramework = TestFramework.TESTNG }
"mockmvc" | { properties.testMode = TestMode.MOCKMVC }
"webclient" | { properties.testMode = TestMode.WEBTESTCLIENT }
}
@@ -1133,6 +1163,9 @@ class SpringTestMethodBodyBuildersSpec extends Specification implements WireMock
"spock" | {
properties.testFramework = TestFramework.SPOCK
} | ['''assertThatRejectionReasonIsNull(parsedJson.read("\\$.rejectionReason"))''', '''assertThatLocationIsNull(response.header("Location"))''']
"testng" | {
properties.testFramework = TestFramework.TESTNG
} | ['''assertThatRejectionReasonIsNull(parsedJson.read("$.rejectionReason"))''', '''assertThatLocationIsNull(response.header("Location"))''']
"mockmvc" | {
properties.testMode = TestMode.MOCKMVC
} | ['''assertThatRejectionReasonIsNull(parsedJson.read("$.rejectionReason"))''', '''assertThatLocationIsNull(response.header("Location"))''']
@@ -1205,6 +1238,7 @@ class SpringTestMethodBodyBuildersSpec extends Specification implements WireMock
where:
methodBuilderName | methodBuilder | bodyString
"spock" | { properties.testFramework = TestFramework.SPOCK } | '"street":"Light Street"'
"testng" | { properties.testFramework = TestFramework.TESTNG }| '\\"street\\":\\"Light Street\\"'
"mockmvc" | { properties.testMode = TestMode.MOCKMVC } | '\\"street\\":\\"Light Street\\"'
"webclient" | { properties.testMode = TestMode.WEBTESTCLIENT } | '\\"street\\":\\"Light Street\\"'
@@ -1238,6 +1272,7 @@ class SpringTestMethodBodyBuildersSpec extends Specification implements WireMock
where:
methodBuilderName | methodBuilder | bodyString
"spock" | { properties.testFramework = TestFramework.SPOCK } | '"street":"Light Street"'
"testng" | { properties.testFramework = TestFramework.TESTNG }| '\\"street\\":\\"Light Street\\"'
"mockmvc" | { properties.testMode = TestMode.MOCKMVC } | '\\"street\\":\\"Light Street\\"'
"webclient" | { properties.testMode = TestMode.WEBTESTCLIENT } | '\\"street\\":\\"Light Street\\"'
@@ -1278,6 +1313,7 @@ class SpringTestMethodBodyBuildersSpec extends Specification implements WireMock
where:
methodBuilderName | methodBuilder
"spock" | { properties.testFramework = TestFramework.SPOCK }
"testng" | { properties.testFramework = TestFramework.TESTNG }
"mockmvc" | { properties.testMode = TestMode.MOCKMVC }
"webclient" | { properties.testMode = TestMode.WEBTESTCLIENT }
}
@@ -1307,6 +1343,7 @@ World.''')
methodBuilderName | methodBuilder | bodyString
"spock" | { properties.testFramework = TestFramework.SPOCK } | """'''hello,
World.'''"""
"testng" | { properties.testFramework = TestFramework.TESTNG }| '"hello,\\nWorld."'
"mockmvc" | { properties.testMode = TestMode.MOCKMVC } | '"hello,\\nWorld."'
"webclient" | { properties.testMode = TestMode.WEBTESTCLIENT } | '"hello,\\nWorld."'
}
@@ -1359,6 +1396,12 @@ World.'''"""
""".param('formParameter', '''"formParameterValue"'''""",
""".param('someBooleanParameter', 'true')""",
""".multiPart('file', 'filename.csv', 'file content'.bytes, 'application/json')"""]
"testng" | {
properties.testFramework = TestFramework.TESTNG
} | ['"Content-Type", "multipart/form-data;boundary=AaB03x"',
'.param("formParameter", "\\"formParameterValue\\"")',
'.param("someBooleanParameter", "true")',
'.multiPart("file", "filename.csv", "file content".getBytes(), "application/json");']
"mockmvc" | {
properties.testMode = TestMode.MOCKMVC
} | ['"Content-Type", "multipart/form-data;boundary=AaB03x"',
@@ -1418,6 +1461,12 @@ World.'''"""
""".param('formParameter', '''"formParameterValue"'''""",
""".param('someBooleanParameter', 'true')""",
""".multiPart('file', 'filename.csv', 'file content'.bytes)"""]
"testng" | {
properties.testFramework = TestFramework.TESTNG
} | ['"Content-Type", "multipart/form-data;boundary=AaB03x"',
'.param("formParameter", "\\"formParameterValue\\"")',
'.param("someBooleanParameter", "true")',
'.multiPart("file", "filename.csv", "file content".getBytes());']
"mockmvc" | {
properties.testMode = TestMode.MOCKMVC
} | ['"Content-Type", "multipart/form-data;boundary=AaB03x"',
@@ -1470,6 +1519,10 @@ World.'''"""
properties.testFramework = TestFramework.SPOCK
} | ['"Content-Type", "multipart/form-data;boundary=AaB03x"',
""".multiPart('file', 'file', [100, 117, 100, 97] as byte[])"""]
"testng" | {
properties.testFramework = TestFramework.TESTNG
} | ['"Content-Type", "multipart/form-data;boundary=AaB03x"',
'.multiPart("file", "file", new byte[] {100, 117, 100, 97});']
"mockmvc" | {
properties.testMode = TestMode.MOCKMVC
} | ['"Content-Type", "multipart/form-data;boundary=AaB03x"',
@@ -1520,6 +1573,12 @@ World.'''"""
""".param('formParameter', '''"formParameterValue"'''""",
""".param('someBooleanParameter', 'true')""",
""".multiPart('file', toString(), 'file content'.bytes)"""]
"testng" | {
properties.testFramework = TestFramework.TESTNG
} | ['"Content-Type", "multipart/form-data;boundary=AaB03x"',
'.param("formParameter", "\\"formParameterValue\\"")',
'.param("someBooleanParameter", "true")',
'.multiPart("file", toString(), "file content".getBytes());']
"mockmvc" | {
properties.testMode = TestMode.MOCKMVC
} | ['"Content-Type", "multipart/form-data;boundary=AaB03x"',
@@ -1572,6 +1631,7 @@ World.'''"""
where:
methodBuilderName | methodBuilder
"spock" | { properties.testFramework = TestFramework.SPOCK }
"testng" | { properties.testFramework = TestFramework.TESTNG }
"mockmvc" | { properties.testMode = TestMode.MOCKMVC }
"webclient" | { properties.testMode = TestMode.WEBTESTCLIENT }
}
@@ -1666,6 +1726,7 @@ World.'''"""
where:
methodBuilderName | methodBuilder
"spock" | { properties.testFramework = TestFramework.SPOCK }
"testng" | { properties.testFramework = TestFramework.TESTNG }
"mockmvc" | { properties.testMode = TestMode.MOCKMVC }
"webclient" | { properties.testMode = TestMode.WEBTESTCLIENT }
}
@@ -1731,6 +1792,7 @@ World.'''"""
where:
methodBuilderName | methodBuilder
"spock" | { properties.testFramework = TestFramework.SPOCK }
"testng" | { properties.testFramework = TestFramework.TESTNG }
"mockmvc" | { properties.testMode = TestMode.MOCKMVC }
"webclient" | { properties.testMode = TestMode.WEBTESTCLIENT }
}
@@ -1768,6 +1830,7 @@ World.'''"""
where:
methodBuilderName | methodBuilder
"spock" | { properties.testFramework = TestFramework.SPOCK }
"testng" | { properties.testFramework = TestFramework.TESTNG }
"mockmvc" | { properties.testMode = TestMode.MOCKMVC }
"webclient" | { properties.testMode = TestMode.WEBTESTCLIENT }
}
@@ -1801,6 +1864,7 @@ World.'''"""
where:
methodBuilderName | methodBuilder
"spock" | { properties.testFramework = TestFramework.SPOCK }
"testng" | { properties.testFramework = TestFramework.TESTNG }
"mockmvc" | { properties.testMode = TestMode.MOCKMVC }
"webclient" | { properties.testMode = TestMode.WEBTESTCLIENT }
}
@@ -1830,6 +1894,7 @@ World.'''"""
where:
methodBuilderName | methodBuilder | bodyDefinitionString
"spock" | { properties.testFramework = TestFramework.SPOCK } | '.when().async()'
"testng" | { properties.testFramework = TestFramework.TESTNG }| '.when().async()'
"mockmvc" | { properties.testMode = TestMode.MOCKMVC } | '.when().async()'
}
@@ -1863,6 +1928,7 @@ World.'''"""
where:
methodBuilderName | methodBuilder
"spock" | { properties.testFramework = TestFramework.SPOCK }
"testng" | { properties.testFramework = TestFramework.TESTNG }
"mockmvc" | { properties.testMode = TestMode.MOCKMVC }
}
@@ -1896,6 +1962,7 @@ World.'''"""
where:
methodBuilderName | methodBuilder
"spock" | { properties.testFramework = TestFramework.SPOCK }
"testng" | { properties.testFramework = TestFramework.TESTNG }
"mockmvc" | { properties.testMode = TestMode.MOCKMVC }
"webclient" | { properties.testMode = TestMode.WEBTESTCLIENT }
}
@@ -2298,6 +2365,7 @@ DocumentContext parsedJson = JsonPath.parse(json);
where:
methodBuilderName | methodBuilder | endOfLineRegExSymbol
"spock" | { properties.testFramework = TestFramework.SPOCK } | '\\$'
"testng" | { properties.testFramework = TestFramework.TESTNG }| '$'
"mockmvc" | { properties.testMode = TestMode.MOCKMVC } | '$'
"webclient" | { properties.testMode = TestMode.WEBTESTCLIENT } | '$'
}
@@ -2330,6 +2398,7 @@ DocumentContext parsedJson = JsonPath.parse(json);
where:
methodBuilderName | methodBuilder
"spock" | { properties.testFramework = TestFramework.SPOCK }
"testng" | { properties.testFramework = TestFramework.TESTNG }
"mockmvc" | { properties.testMode = TestMode.MOCKMVC }
"webclient" | { properties.testMode = TestMode.WEBTESTCLIENT }
}
@@ -2366,6 +2435,7 @@ DocumentContext parsedJson = JsonPath.parse(json);
where:
methodBuilderName | methodBuilder
"spock" | { properties.testFramework = TestFramework.SPOCK }
"testng" | { properties.testFramework = TestFramework.TESTNG }
"mockmvc" | { properties.testMode = TestMode.MOCKMVC }
"webclient" | { properties.testMode = TestMode.WEBTESTCLIENT }
}
@@ -2398,6 +2468,7 @@ DocumentContext parsedJson = JsonPath.parse(json);
//order is inverted cause Intellij didn't parse this properly
methodBuilderName | methodBuilder | expectedAssertion
"spock" | { properties.testFramework = TestFramework.SPOCK } | """responseBody == '''{"a":1}\\n{"a":2}'''"""
"testng" | { properties.testFramework = TestFramework.TESTNG }| '''assertThat(responseBody).isEqualTo("{\\"a\\":1}\\n{\\"a\\":2}'''
"mockmvc" | { properties.testMode = TestMode.MOCKMVC } | '''assertThat(responseBody).isEqualTo("{\\"a\\":1}\\n{\\"a\\":2}'''
"webclient" | { properties.testMode = TestMode.WEBTESTCLIENT } | '''assertThat(responseBody).isEqualTo("{\\"a\\":1}\\n{\\"a\\":2}'''
}
@@ -2432,6 +2503,9 @@ DocumentContext parsedJson = JsonPath.parse(json);
"spock" | {
properties.testFramework = TestFramework.SPOCK
} | { String testContents -> testContents.contains("""responseBody ==~ java.util.regex.Pattern.compile('true|false')""") }
"testng" | {
properties.testFramework = TestFramework.TESTNG
} | { String testContents -> testContents.contains("""assertThat(responseBody).matches("true|false");""") }
"mockmvc" | {
properties.testMode = TestMode.MOCKMVC
} | { String testContents -> testContents.contains("""assertThat(responseBody).matches("true|false");""") }
@@ -2477,6 +2551,7 @@ DocumentContext parsedJson = JsonPath.parse(json);
//order is inverted cause Intellij didn't parse this properly
methodBuilderName | methodBuilder | expectedAssertion
"spock" | { properties.testFramework = TestFramework.SPOCK } | '''responseBody == "{\\"a\\":1}\\n{\\"a\\":2}"'''
"testng" | { properties.testFramework = TestFramework.TESTNG }| '''assertThat(responseBody).isEqualTo("{\\"a\\":1}\\n{\\"a\\":2}'''
"mockmvc" | { properties.testMode = TestMode.MOCKMVC } | '''assertThat(responseBody).isEqualTo("{\\"a\\":1}\\n{\\"a\\":2}'''
"webclient" | { properties.testMode = TestMode.WEBTESTCLIENT } | '''assertThat(responseBody).isEqualTo("{\\"a\\":1}\\n{\\"a\\":2}'''
}
@@ -2507,6 +2582,9 @@ DocumentContext parsedJson = JsonPath.parse(json);
"spock" | {
properties.testFramework = TestFramework.SPOCK
}
"testng" | {
properties.testFramework = TestFramework.TESTNG
}
"mockmvc" | {
properties.testMode = TestMode.MOCKMVC
}
@@ -2548,6 +2626,7 @@ DocumentContext parsedJson = JsonPath.parse(json);
where:
methodBuilderName | methodBuilder
"spock" | { properties.testFramework = TestFramework.SPOCK }
"testng" | { properties.testFramework = TestFramework.TESTNG }
"mockmvc" | { properties.testMode = TestMode.MOCKMVC }
"jaxrs-spock" | {
properties.testFramework = TestFramework.SPOCK; properties.testMode = TestMode.JAXRSCLIENT
@@ -2584,6 +2663,9 @@ DocumentContext parsedJson = JsonPath.parse(json);
"spock" | {
properties.testFramework = TestFramework.SPOCK
} | { String body -> body.contains("body('''12000''')") } | { String body -> body.contains("responseBody == '12000'") }
"testng" | {
properties.testFramework = TestFramework.TESTNG
} | { String body -> body.contains('body("12000")') } | { String body -> body.contains('assertThat(responseBody).isEqualTo("12000");') }
"mockmvc" | {
properties.testMode = TestMode.MOCKMVC
} | { String body -> body.contains('body("12000")') } | { String body -> body.contains('assertThat(responseBody).isEqualTo("12000");') }
@@ -2682,6 +2764,9 @@ DocumentContext parsedJson = JsonPath.parse(json);
"spock" | {
properties.testFramework = TestFramework.SPOCK
} | { String body -> body.contains("""response.header("Authorization") == 'foo secret bar'""") }
"testng" | {
properties.testFramework = TestFramework.TESTNG
} | { String body -> body.contains('assertThat(response.header("Authorization")).isEqualTo("foo secret bar");') }
"mockmvc" | {
properties.testMode = TestMode.MOCKMVC
} | { String body -> body.contains('assertThat(response.header("Authorization")).isEqualTo("foo secret bar");') }
@@ -2742,6 +2827,7 @@ DocumentContext parsedJson = JsonPath.parse(json);
where:
methodBuilderName | methodBuilder
"spock" | { properties.testFramework = TestFramework.SPOCK }
"testng" | { properties.testFramework = TestFramework.TESTNG }
"mockmvc" | { properties.testMode = TestMode.MOCKMVC }
"jaxrs-spock" | {
properties.testFramework = TestFramework.SPOCK; properties.testMode = TestMode.JAXRSCLIENT
@@ -2867,6 +2953,7 @@ DocumentContext parsedJson = JsonPath.parse(json);
where:
methodBuilderName | methodBuilder
"spock" | { properties.testFramework = TestFramework.SPOCK }
"testng" | { properties.testFramework = TestFramework.TESTNG }
"mockmvc" | { properties.testMode = TestMode.MOCKMVC }
"jaxrs-spock" | {
properties.testFramework = TestFramework.SPOCK; properties.testMode = TestMode.JAXRSCLIENT

View File

@@ -162,6 +162,9 @@ class XmlMethodBodyBuilderSpec extends Specification {
"spock" | {
properties.testFramework = TestFramework.SPOCK
}
"testng" | {
properties.testFramework = TestFramework.TESTNG
}
"junit" | {
properties.testMode = TestMode.MOCKMVC
}

View File

@@ -1739,6 +1739,9 @@ response:
"mockmvc" | {
properties.testMode = TestMode.MOCKMVC
} | { String testContents -> testContents.contains("""assertThat(responseBody).matches("true|false");""") }
"mockmvc-testng" | {
properties.testFramework = TestFramework.TESTNG; properties.testMode = TestMode.MOCKMVC
} | { String testContents -> testContents.contains("""assertThat(responseBody).matches("true|false");""") }
"jaxrs-spock" | {
properties.testFramework = TestFramework.SPOCK; properties.testMode = TestMode.JAXRSCLIENT
} | { String testContents -> testContents.contains("""responseBody ==~ java.util.regex.Pattern.compile("true|false")""") }
@@ -1814,6 +1817,9 @@ response:
"mockmvc" | {
properties.testMode = TestMode.MOCKMVC
}
"mockmvc-testng" | {
properties.testFramework = TestFramework.TESTNG; properties.testMode = TestMode.MOCKMVC
}
"jaxrs-spock" | {
properties.testFramework = TestFramework.SPOCK; properties.testMode = TestMode.JAXRSCLIENT
}
@@ -1851,6 +1857,9 @@ response:
methodBuilderName | methodBuilder
"spock" | { properties.testFramework = TestFramework.SPOCK }
"mockmvc" | { properties.testMode = TestMode.MOCKMVC }
"mockmvc-testng" | {
properties.testFramework = TestFramework.TESTNG; properties.testMode = TestMode.MOCKMVC
}
"jaxrs-spock" | {
properties.testFramework = TestFramework.SPOCK; properties.testMode = TestMode.JAXRSCLIENT
}
@@ -1889,6 +1898,9 @@ response:
"mockmvc" | {
properties.testMode = TestMode.MOCKMVC
} | { String body -> body.contains('body("12000")') } | { String body -> body.contains('assertThat(responseBody).isEqualTo("12000");') }
"mockmvc-testng" | {
properties.testFramework = TestFramework.TESTNG; properties.testMode = TestMode.MOCKMVC
} | { String body -> body.contains('body("12000")') } | { String body -> body.contains('assertThat(responseBody).isEqualTo("12000");') }
"jaxrs-spock" | {
properties.testFramework = TestFramework.SPOCK; properties.testMode = TestMode.JAXRSCLIENT
} | { String body -> body.contains(""".build("GET", entity("12000", "text/plain"))""") } | { String body -> body.contains('responseBody == "12000"') }