简体   繁体   中英

dotnet core: can't run unit tests

I am developing an application using dotnet core. When I try to run the unit tests, I receive the following message:

The active test run was aborted. Reason: Unable to communicate with test host process.

I already checked my .csproj files, I have uninstaled and instaled again dotnet core, tried to rebuild the projects, tried to restore the packages again, searched for code errors, but I have no clue of what is happening.

I am using Ubuntu 16.04.

The project that is facing the issue is available here: https://github.com/andremteixeira/Personal-Accounting

You have created a stack overflow exception that unfortunately completely crashes the test host process..

The problem is:

  1. Any operator is called
  2. This calls CheckNullity
  3. CheckNullity has a a == null comparison
  4. This invokes the custom bool operator == (Money a, Money b)
  5. Which forwards to bool IsEquivalent(Money a, Money b)
  6. Which has a check for a != null
  7. Which invokes the custom operator bool operator != (Money a, Money b)
  8. Which has a check for a == null
  9. This lands at 4. again

if I replace

if (a == null || b == null)

with

if (Object.ReferenceEquals(a, null) || Object.ReferenceEquals(b, null))

in CheckNullity it breaks the cycle and all the tests run.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM