thymeleaf-testing icon indicating copy to clipboard operation
thymeleaf-testing copied to clipboard

Better JUnit integration

Open danielfernandez opened this issue 12 years ago • 4 comments

Enhance integration with JUnit in order to allow each thymeleaf test (.thtest) to be counted by JUnit as a separated test, so that execution summary figures better reflect the real amount of executed tests.

danielfernandez avatar Jan 23 '14 21:01 danielfernandez

This would be awesome to have IMO. Have you seen what I've been doing to make each test file equate to a single JUnit test? https://github.com/ultraq/thymeleaf-layout-dialect/blob/master/Tests/nz/net/ultraq/thymeleaf/tests/decorator/DecoratorTester.java And that's just 1 of about 4 files like it. Soooo much boilerplate!

ultraq avatar Jan 23 '14 22:01 ultraq

This would help us a lot too! Especially since we are using the testing framework to test over 500 templates used in our applications.

Kleeven81 avatar Jan 24 '14 06:01 Kleeven81

I finally got tired of the boilerplate involved with hooking up a new thtest file w/ JUnit, so I went looking for a way to dynamically generate a test for every Thymeleaf test file, and stumbled across JUnit's Parameterized tests feature. I ended-up creating this class (JUnitThymeleafTestExecutor.java) to replace all the other ones I had that just mapped Thymeleaf tests to JUnit tests.

It's not exactly the same as it was before (tests are still reported on separately, but aren't grouped by package any more as they're all effectively run by this single class), but maybe it's a good starting point for this issue? I'm just glad I don't have to write any more @Test-annotated methods, just Thymeleaf test files! :)

ultraq avatar Jun 07 '14 05:06 ultraq

See https://github.com/opensource21/fuwesta/blob/master/fuwesta-core/src/test/java/de/ppi/fuwesta/thymeleaf/basic/ThymeleafTest.java for an approach. There each testfile is a separate JUnit-Test.

opensource21 avatar Sep 01 '14 13:09 opensource21