apache / apache/grails-intellij-plugin

IntelliJ unit test give a different result then Grails unit test

Open
#151 0 comments 0 reactions 0 assignees View on GitHub
bug imported-from-youtrack
Dominant language
Java
Stars
17
Forks
4
Avg merge
5d 15h
Merged PRs (30d)
4

Description

When running Controller unit tests with Grails, they work. When running unit tests with the Junit runner in IntelliJ, they fail. I've debugged the issue, and it seems that in DefaultHtmlRenderer, the 'suffix' field is not populated from the Config.groovy file when running the test in IntelliJ. In Grails however, the suffix is loaded (which is populated with 'Instance'). So, when having a test like:
```
void "Test the create action returns the correct model"() {
when:"The create action is executed"
controller.create()

then:"The model is correctly created"
model.profileInstance!= null
}
```
The code succeeds in Grails, since there is a field called 'profileInstance'. When running the test in IntelliJ, the model is also populated, but then with the field 'profile' (see screenshot).

These are just standard generated tests (by Grails), nothing is added or removed in them.

---

*Imported from [IDEA-121016](https://youtrack.jetbrains.com/issue/IDEA-121016) · Type: Bug · Votes: 0*
*Comments, attachments, dates and reporter are not part of the export — follow the link above for the full history.*

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce the generated controller unit test with both the Grails runner and IntelliJ's JUnit runner, then inspect DefaultHtmlRenderer and the Config.groovy configuration path. Compare how the suffix is populated in each environment. Done means both runners produce the same model key, including profileInstance.

Written by the indexing model from the issue text.

Assessment

Tech stack
groovy
Domain
testing, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.