-
-
Notifications
You must be signed in to change notification settings - Fork 93
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 unit tests for related entities on the generated app #397
Comments
Does the Java template generate these test? I was going to peek at the implementation if it does. |
Last time I checked the main Jhipster generator didn't generate tests for relationships. The idea would be to create unit tests that:
|
@ivanmonteiro can I take this? |
Sure, if you have questions let me know |
@ivanmonteiro I just reviewed the generated codes and wants to confirm several things: The only entities generated are User, Role, and UserRole. So that means we need to create/update/deletion tests that will create/update/delete the User and its Roles. Is this correct? |
When we create entities, currently the generator creates ControllerIntTest.cs tests: Line 206 in e9d40cc
It tests controllers actions like save/update/delete and check if the a child entity is null or not. It only checks if it is required. But it does not create child entities and save together with the parent. Like if we have a Person entity that has an Address child entity, it does not create the the Person entity with its Address. Ideally whe should have tests that both creates the parent AND child entity, and tests the relationship:
So the _persistClass_ControllerIntTest.cs.ejs template can be a starting point, but I have a suggestion: Keep it simple, if you can. The template file I mentioned (_persistClass_ControllerIntTest.cs.ejs) is more like an integration test (more complex). But this issue could probably be solved creating unit tests (simple), and could use the repository (or service classes) directly in the test instead of creating an httpClient, calling the controllers, etc... If you have more questions feel free to ask. |
@ivanmonteiro every time I tried to add a relationship to an entity it was always error:
This error happens in two scenarios:
Should I fix the error first? |
Overview of the feature request
Add unit tests for related entities on the generated dotnet application.
As an example:
Unit tests for Employee should test adding and removing its Department relationship.
Motivation for or Use Case
Currently the unit tests only adds/removes the main entity.
Changes to the generator may cause issues regarding relationships and are not caught by tests.
This is important to make sure that new PR's are not breaking relationship functionality at this project.
Related issues or PR
The text was updated successfully, but these errors were encountered: