Showing content from https://github.com/pmd/pmd/issues/1318 below:
[test] Kotlin DSL to ease test writing · Issue #1318 · pmd/pmd · GitHub
So I put together a nice Kotlin DSL to match AST nodes and plugged it into our build. You can check it out here
There are two components to it:
- A language-agnostic node matcher DSL, that lives in pmd-test. This is basically what you've seen in this prototype
- A language-specific DSL to write full tests in a very concise way. I only implemented it for Java for now, and it can probably be somewhat abstracted. You can find it in pmd-java/src/test/kotlin, along with some example tests that were either converted from java or written from scratch. I based it on KotlinTest's FunSpec because it's much more extensible (and more readable) than JUnit-style tests. For example, it allows generating tests for several language versions transparently, on the same test case:
https://github.com/oowekyala/pmd/blob/0922f2b706e4cc4ae9900733a43b27fd18403f49/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/Java11Test.kt#L78-L90
The remaining problem is just, that I'm not sure Kotlin is well supported by Eclipse atm. I've tried it and it doesn't look like you can run the tests from the IDE, even when using a JUnit-style like syntax like here. Is this is a deal breaker?
Also, I'm not certain packaging the DSL in pmd-test is the best idea
RetroSearch is an open source project built by @garambo
| Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4