allure-framework/allure-java

🐞: Spock2 BDD blocks missing from Allure report when dependencies in specific order

karltiirik opened this issue · 3 comments

What happened?

Project setup: Maven, Groovy, Spock2, Allure

Reproduction steps:

  1. Project: karltiirik/spock-restassured-allure@30ff03c
  2. Run tests ./mvnw clean test
  3. Serve Allure report ./mvnw allure:serve
  4. Spock2 BDD steps present in the report
  5. Change Spock2 and Allure dependency order: karltiirik/spock-restassured-allure@4139b76
  6. Run tests ./mvnw clean test
  7. Serve Allure report ./mvnw allure:serve

Expected:
Kuvatõmmis 2023-06-16 140234

Actual:
Kuvatõmmis 2023-06-16 141218

What Allure Integration are you using?

allure-rest-assured, allure-spock2

What version of Allure Integration you are using?

2.22.2

What version of Allure Report you are using?

2.22.2

Code of Conduct

  • I agree to follow this project's Code of Conduct

#871 is possibly related to this issue.

baev commented

Steps blocks will appear in the report only if allure-spock2 is located in the classpath before spock dependencies. The reason is that Spock uses labels on statements (from GOTO times) to mark the blocks. And then Spock groovy processor rewrites such statements. And after rewriting, labels are gone. Allure Spock integration uses the same processor to insert steps before statements with such labels, although if Spock processes the file first, labels are gone, and there is nothing we can do about it.

According to the ASTTransformation docs, there is no way to specify the order of execution, although, at the moment, it seems that transformations are applied in the order they are discovered, which is the order they are located in the classpath. Both Maven & Grade build classpaths from top to bottom, so declaring allure-spock2 dependency first should do the trick.

@baev thank you for the in-depth answer! Will just add a comment to my project that allure-spock2 dep will need to be defined before the spock dependency.