Is there a way to have nested tests like JUnit 5 in Spock?
Asked Answered
A

0

6

Is there a way to have nested tests like JUnit 5 in Spock?

There are a lot of tests for a particular class and I want to group them for better understanding and easy viewing.

JUnit offers Nested tests (https://junit.org/junit5/docs/current/user-guide/#writing-tests-nested). So I was wondering if, I could do something similar in Spock or use Spock in conjunction with JUnit 5.

Aged answered 24/12, 2020 at 13:2 Comment(2)
Welcome to SO. Instead of comparing feature lists, better explain what you want to achieve with your test and show some code. I do not really see the benefit of that JUnit feature if there is no use case it addresses or problem it solves more elegantly than another way of organising tests. I would even argue it looks quite ugly. There might be cases where this is very useful, though. So please present yours instead of presenting an XY problem, explaining how you want to do something instead of explaining what you want to do.Chicane
Hi, Harsh thanks for this question if you correct it a bit would be cool, but I really miss this feature in Spock, although I am a big fan of Spock. So the short answer is that no there is no way to do this in Spock. On the other hand, you try to avoid this in normal life scenarios :) , 99% of the time you do not need to compleacate your tests, but for 1% cases this would be amazing feature indeed.Blake

© 2022 - 2024 — McMap. All rights reserved.