-
Notifications
You must be signed in to change notification settings - Fork 506
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
Add KtLintAssertThat for asserting unit tests in a fluent style #1444
Add KtLintAssertThat for asserting unit tests in a fluent style #1444
Conversation
Sry, I don't have much time to review this in full, but if you're going to expose this to consumers (looking at |
Done. Learned a again a bit about gradle ;-)
Should junit also be exposed as API dependency? |
No, not really, because you are not exposing any junit types as API (in case of assertj - KtLintAssertThat extends AbastractAssert, which will be part of the public API, hence we need to expose it) |
# Conflicts: # ktlint-ruleset-standard/src/test/kotlin/com/pinterest/ktlint/ruleset/standard/IndentationRuleTest.kt
Tnx for explaining. |
* Removed StandardRuleSetIntegrationTest as it is can be written as a simple unit test without dependency on the no-used-import rule. The test is moved the StringTemplateRuleTest.
This PR consists of adding a new KtLintAssertThat API plus a massive rewrite of all tests using the new test API. Also all spec files have been replaced with normal unit tests. Due to shere volume of change, I do not expect anybody to be able/willing to review this. So, I will just merge it when builds succeeds. Note that during this endeavour, I encountered multiple potential bug and issues. I have left TODO remarks in Test classes and added Tests marked with @disabled where applicable and created #1456 as reminder to fix them. |
Description
AssertJ style assertion for verifying KtLint rules. This class is intended to be used as follows:
Create an assertThat assertion for a specific rule or set of rules. If possible define it at the class level
The created assertThat can than be used in test method similar to the normal assertThat:
The ktlintAssertThat provides access to methods like:
All tests of the IndentationRule, with exception of the tests using the spec file, have been rewritten with ktlintAssertThat. Other classes will be rewritten as well but I would like to get some feedback on the idea.
Checklist
CHANGELOG.md
is updatedIn case of adding a new rule:
README.md
is updated