RichardWarburton / lambda-behave

A modern testing and behavioural specification framework for Java 8
http://richardwarburton.github.io/lambda-behave/
MIT License
253 stars 52 forks source link

Include class name in JUnit name and child descriptions #76

Closed hcoles closed 10 years ago

hcoles commented 10 years ago

com.insightfullogic.lambdabehave.JunitSuiteRunner doesn't interact too well with the eclipse JUnit runner (and possibly other tools).

It is not currently possible to jump to a test/spec implementation and running single test cases does not work.

If the name of the defining spec class is used instead of the suite name then both these behaviours work.

RichardWarburton commented 10 years ago

The problem with this suggestion is that it means that the name of the suite isn't the name of the suite. If you've got code that says describe("the different forms of expectation" then the name of that suite is the different forms of expectation and not ExpectationSpec.

I don't mind suffixing it, so in that case it would be visible as the different forms of expectation (ExpectationSpec). Would that address your issue?

I've thought about the re-running a single test scenario and as far as I can tell really that's just impossible for lambda behave given the way that junit runners work. I hope soon to find enough time to write a couple of IDE plugins specifically for lambda-behave, which is IMHO the right way to address this problem.

hcoles commented 10 years ago

I don't think suffixing will help, eclipse and other tools expect the suite name to be a class. Other junit runners also break this convention, but it's nicer to work with one that doesn't.

As far as I can tell using the classname allows running single test cases without any issue (other cases don't seem to run + the one you select does) - but it obviously doesn't give you the naming you'd like.

What might work would be to introduce nesting - so that ExpectationSpec is presented as the top level suite and then contains a nested suite named "the different forms of expectation".

This would definitely allow navigation to the class, not sure if it would allow individual test selection to work.

Nesting would also allow support for classes containing multiple describes - current expected behaviour if you do this is not clear.

hcoles commented 10 years ago

Had a quick play with this locally and created a runner that presents any "describes" as sub-suites of the containing class.

This allows navigation to the top level class in eclipse, but I've not found a way to get individual test selection to work with the eclipse junit runner.

I personally think this is an improvement, if you're interested I can clean it up and create a PR.

RichardWarburton commented 10 years ago

That sounds good and would be most appreciated.

RichardWarburton commented 10 years ago

It probably would also resolve #57

RichardWarburton commented 10 years ago

Resolved by PR #76