Failing Unit Tests with most recent NOP version

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
5 years ago
I just downloaded the source code and built the app in VS.

I am planning on extending NOP so I ran the unit tests while I was setting up my CI/CD pipeline.

I am getting 20 failed tests.  

Anyone else seeing this?

I have not dug into it fully - but a few of them are null reference exceptions from the moqs not being set-up or set-up correctly?
5 years ago
How do you run the test ?
I saw this post https://www.nopcommerce.com/boards/t/24005/run-all-tests.aspx
In VS Menu
Test -> Run -> All Tests

Its the same for me builds and get

[16/05/2018 5:41:19 PM Informational] ------ Load Playlist started ------
[16/05/2018 5:41:19 PM Informational] ========== Load Playlist finished (0:00:00.1055253) ==========
[16/05/2018 5:44:10 PM Informational] ------ Run test started ------
[16/05/2018 5:44:16 PM Warning] No test is available in M:\Production\nopCommerce_4.00_Source\Tests\Nop.Core.Tests\bin\Debug\net461\Nop.Core.Tests.dll M:\Production\nopCommerce_4.00_Source\Tests\Nop.Data.Tests\bin\Debug\net461\Nop.Data.Tests.dll M:\Production\nopCommerce_4.00_Source\Tests\Nop.Services.Tests\bin\Debug\net461\Nop.Services.Tests.dll M:\Production\nopCommerce_4.00_Source\Tests\Nop.Tests\bin\Debug\net461\Nop.Tests.dll M:\Production\nopCommerce_4.00_Source\Tests\Nop.Web.MVC.Tests\bin\Debug\net461\Nop.Web.MVC.Tests.dll.
Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again.
5 years ago
NOP uses nunit.  It looks like you do not have the nunit adapter installed.  That's why the tests are not picking up.

I use resharper and used it to run the tests.  I get 20 of 500+ tests failing.
5 years ago
I guess it is expected, over 90% passed are very good. I think we could make those 10% works contributing code changes for those unit tests. but for now, i guess for you you could just by pass those failed unit tests or add attribute to skip those unit tests to complete CI.
5 years ago
Not sure I share the same sentiment.  90% code coverage is ok - not great.  I have our coverage filter set to 95.  If one of my developers cannot get it there, we have a talk.  Maybe we refactor so we can get more testable code.

Failing tests are not ok.  It implies something changed and possibly broke the app.

Not to mention a failing test will stop the CI build.

Ignoring tests is a bad precedent.  If they are no longer relevant then it should be removed.  

I was curious if anyone else saw this.  I may just fix them and get it submitted.  Good way to become more familiar with the app.
5 years ago
johndbennett, I agree with you totally on test cases cannot be ignored. However, this is an open source project and it needs many of us in the community help building and testing test cases. I was not saying the coverage is 90% and considering this is a open source project and I don't know how many percentage covered. If you look at in github, not many open source projects have unit tests... I am just saying if you are developer and if you see the test failed, then perhaps we as developers should consider fixing it.
5 years ago
Ok I installed Nunit adapter and tests are working
560 Tests in total
One issue was settings to use x86 rather than x64
Then I only had failure on 2 tests

Failed on Can_publish_event() and Can_get_shipping_total_discount_excluding_tax()

Im only new to this but from what I can see one is a null value - seems to be the test setup not correct
The other still to work it out
5 years ago
Weird.  You get only two failures.

I am going to dig into it when I get a chance.
5 years ago
Hey guys,

Not sure if this is gonna help anyone, but I was also getting ~20 failed tests when running the entire suite.

What was strange was that these tests all passed if they were run individually.

I was able to fix it by adding the below into \Tests\Nop.Services.Tests\ExportImport\ExportManagerTests.cs

        [OneTimeTearDown]
        public void TearDown()
        {
            EngineContext.Replace(null);
        }

Seems like in the other places the EngineContext is replaced (Tests\Nop.Services.Tests\Catalog\PriceCalculationServiceTests.cs, Tests\Nop.Services.Tests\Catalog\PriceFormatterTests.cs) the context is reset at the end.  ExportManagerTests was missing this.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.