Skip to content
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

refactor(test): improve QueryValidator testing strategy #3731

Open
ndr-brt opened this issue Dec 21, 2023 · 8 comments
Open

refactor(test): improve QueryValidator testing strategy #3731

ndr-brt opened this issue Dec 21, 2023 · 8 comments
Assignees
Labels
good first issue Good for newcomers refactoring Cleaning up code and dependencies
Milestone

Comments

@ndr-brt
Copy link
Member

ndr-brt commented Dec 21, 2023

Feature Request

Currently the QueryValidator is tested integrated within the services, that's not a great approach.
It would be better to separate the responsibility (test the behavior in the validator test and the interaction in the service test)

Which Areas Would Be Affected?

tests

Why Is the Feature Desired?

avoid unnecessary integration tests

Solution Proposal

If possible, provide a (brief!) solution proposal.

Copy link

github-actions bot commented Jan 5, 2024

This issue is stale because it has been open for 14 days with no activity.

@github-actions github-actions bot added the stale Open for x days with no activity label Jan 5, 2024
@ndr-brt ndr-brt removed the stale Open for x days with no activity label Jan 8, 2024
Copy link

This issue is stale because it has been open for 14 days with no activity.

@github-actions github-actions bot added the stale Open for x days with no activity label Jan 23, 2024
@ndr-brt ndr-brt added this to the Backlog milestone Jan 23, 2024
@ndr-brt ndr-brt removed the stale Open for x days with no activity label Jan 23, 2024
@enchobelezirev
Copy link

Hello,

Can I take this issue?

Thanks!

@ndr-brt
Copy link
Member Author

ndr-brt commented Apr 3, 2024

sure, I assigned it to you

@enchobelezirev
Copy link

@ndr-brt Thanks!

@enchobelezirev
Copy link

Hello @ndr-brt,

Just checking to see whether I am on the right track for the issue. As far as I understood the issue it is needed to create a Mock objects of QueryValidator in the "*Service" classes in order to test whether the methods from the Services classes are reacted as expected when the QueryValidator either fails or succeeds during the validation, this is one thing. The other thing is to, possibly, extract the methods from the Service classes which are testing the actual usage of the QueryValidator in a separated "Integration" test.

Please, correct me if I did not get the issue correct.
Thanks!

@ndr-brt
Copy link
Member Author

ndr-brt commented Apr 5, 2024

@enchobelezirev the QueryValidator is currently instantiated in the services constructor:

  • ContractAgreementServiceImpl
  • ContractDefinitionServiceImpl
  • ContractNegotiationServiceImpl
  • PolicyDefinitionServiceImpl
  • TransferProcessServiceImpl

and its behavior is tested in the test service class (e.g. TransferProcessServiceImplTest.search_validFilter).
This is not good because a change in the query validator could result in multiple failing service tests.

As reported in the issue, the service test should verify the interaction with the queryValidator (and it would need to be injected for that, instead of being instantiated in the constructor as it is now).

Then those validator tests should be moved in a separate place, a good approach could be to have a QueryValidatorFactory that creates instances for different services and some tests that verifies the object created behave in the expected way

@enchobelezirev
Copy link

I did it without the Factory because I thought that the way of creation of QueryValidator should not be changed. If you do not like it, I will change it.

Thanks for the support! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers refactoring Cleaning up code and dependencies
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants