ICustomValidate difference between normal run and integration tests
See original GitHub issue- Your Abp package version : 4.3.0
- Your base framework: .Net Core.
- Exception message and stack trace if available : None
- Steps needed to reproduce the problem.
So I have an AppService (DevisCommandeAppService in the following example) with a specific createDto (DevisCommandeCreateDto in the following example) with a Custom Validation (ICustomValidate), If I use test the create function with swagger I can verify with the debugger that my Custom Validation is really used.
Now I create an additional function in my AppService :
public async Task<DevisCommandeOutputDto> TestAsync()
{
var toto = await Create(new DevisCommandeCreateDto());
return toto;
}
If I try to test this method (TestAsync) with Swagger, the Custom Validation function is no called. Ok let’s say that’s normal.
Now I create a TestCase :
public class TestTestTest : Abp2TestBase
{
private readonly DevisCommandeAppService _app;
public CodeDevisCommandeGeneratorTest()
{
_app = Resolve<DevisCommandeAppService>();
}
[Fact]
public async Task TrucAsync()
{
DevisCommandeOutputDto creationDevisCommande = await _app.TestAsync();
}
}
Here Abp2TestBase
comes directly from the ABP template downloaded off the website (inherit from AbpIntegratedTestBase). If I debug this test, then the Custom Validation on the CreateDto is called.
Unfortunately due to that I can’t be sure that my tests are really testing what’s happening when the application is used by real users.
Hope that helps. I can try to make a full example (in a zip file if needed). I’ll try to update to 4.4.0 soon but by reading the release I’m not very confident it’ll help.
Thanks in advance for any pointers.
Issue Analytics
- State:
- Created 5 years ago
- Comments:16 (7 by maintainers)
Top GitHub Comments
I added another commit where I call the
Create
from another appService and there the Custom Validator is called : https://github.com/seblucas/module-zero-core-template/commit/50e8b72d2ea2483f266dc33939cf25f95e9a3120Hope that will help 😉
@ismcagdas @alirizaadiyahsi
Thanks a lot for your answers, I’ll have to think about that.