question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:closed
  • Created 5 years ago
  • Comments:16 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
seblucascommented, Mar 19, 2019

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/50e8b72d2ea2483f266dc33939cf25f95e9a3120

Hope that will help 😉

0reactions
seblucascommented, Mar 26, 2019

@ismcagdas @alirizaadiyahsi
Thanks a lot for your answers, I’ll have to think about that.

Read more comments on GitHub >

github_iconTop Results From Across the Web

What is the difference between integration and unit tests?
Integration tests: Database persistence is tested. Unit tests: Database access is mocked. Code methods are tested. Share.
Read more >
Unit testing vs integration testing
While writing unit tests is often faster, the reliability of integration tests tends to build more confidence for key stakeholders. Use both ...
Read more >
Unit Test vs. Integration Test: Tell Them Apart and Use Both
Both unit testing and integration testing are types of testing that require coding (in contrast to forms of testing that rely on screen ......
Read more >
Unit Tests vs Integration Tests - The Coders Tower
Integration tests usually run slowly. The idea is test a lot of components at the same time, so, it is normal that the...
Read more >
Integration tests in ASP.NET Core
Integration tests confirm that two or more app components work together to produce an expected result, possibly including every component ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found