New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[test] Kotlin DSL to ease test writing #1318

oowekyala opened this Issue Aug 24, 2018 · 0 comments


None yet
2 participants
Copy link

oowekyala commented Aug 24, 2018

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:

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

@adangel adangel added this to the 6.9.0 milestone Sep 30, 2018

@adangel adangel modified the milestones: 6.9.0, 6.10.0 Oct 27, 2018

@adangel adangel closed this in 544c819 Oct 29, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment