Skip to content

Commit 6ec4af6

Browse files
committedJan 22, 2020
feat: Place tag after consumer name in junit test description
1 parent 5e38e39 commit 6ec4af6

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed
 

‎provider/pact-jvm-provider-junit/src/main/kotlin/au/com/dius/pact/provider/junit/descriptions/DescriptionGenerator.kt

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,16 @@ class DescriptionGenerator<I : Interaction>(
2020
/**
2121
* Builds an instance of junit Description adhering with this logic for building the name:
2222
* If the PactSource is of type <code>BrokerUrlSource</code> and its tag is not empty then
23-
* the test name will be "[tag:#tagname] #consumername - Upon #interaction".
23+
* the test name will be "#consumername [tag:#tagname] - Upon #interaction".
2424
* For all the other cases "#consumername - Upon #interaction"
2525
* @param interaction the Interaction under test
2626
*/
2727
fun generate(interaction: Interaction): Description {
2828
return Description.createTestDescription(testClass.javaClass,
29-
"${this.getNamePrefix()}${pact.consumer.name} - Upon ${interaction.description}")
29+
"${pact.consumer.name} ${this.getTagDescription()}- Upon ${interaction.description}")
3030
}
3131

32-
private fun getNamePrefix(): String {
32+
private fun getTagDescription(): String {
3333
if (pactSource is BrokerUrlSource && pactSource.tag.isNotEmpty()) {
3434
return "[tag:${pactSource.tag}] "
3535
}

‎provider/pact-jvm-provider-junit/src/test/groovy/au/com/dius/pact/provider/junit/descriptions/DescriptionGeneratorTest.groovy

+4-4
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class DescriptionGeneratorTest extends Specification {
3434
def 'when BrokerUrlSource tests description includes tag if present'() {
3535
def interaction = new RequestResponseInteraction('Interaction 1',
3636
[ new ProviderState('Test State') ], new Request(), new Response())
37-
def pact = new RequestResponsePact(new Provider(), new Consumer(), [ interaction ])
37+
def pact = new RequestResponsePact(new Provider(), new Consumer("the-consumer-name"), [ interaction ])
3838

3939
expect:
4040
def pactSource = new BrokerUrlSource('url', 'url', [:], [:], tag)
@@ -43,9 +43,9 @@ class DescriptionGeneratorTest extends Specification {
4343

4444
where:
4545
tag | description
46-
'master' | '[tag:master] consumer - Upon Interaction 1'
47-
null | 'consumer - Upon Interaction 1'
48-
'' | 'consumer - Upon Interaction 1'
46+
'master' | 'the-consumer-name [tag:master] - Upon Interaction 1'
47+
null | 'the-consumer-name - Upon Interaction 1'
48+
'' | 'the-consumer-name - Upon Interaction 1'
4949
}
5050

5151
def 'when non broker pact source tests name are built correctly'() {

0 commit comments

Comments
 (0)
Please sign in to comment.