Building before running unit tests

Answered

When I run a unit test by right-clicking on the green & brown circle in the left margin or by clicking either run button in the unit test sessions window, should I expect Resharper to build my test project before running the test? Should I expect it to build all dependencies as well?

Resharper is not building my test project when I run a test. I'm using Resharper 10. If my memory serves me, I believe all previous versions of Resharper behaved differently -- they built the test project and its dependencies before running the test project.

9 comments
Comment actions Permalink
Official comment

Hello 

On Unit Test session tab, there is a "Options" combobox | Open it | Build Policy | Select needed option.

Thanks!  

Comment actions Permalink

I set the build policy Automation (whole solution) but it still doesn't build. Therefore when I debug the test it says that the source differ from the test being run. I'm using 2016.2.

0
Comment actions Permalink

I am also having this problem. Did you ever get anywhere with this? I added a new .NET Core class library to my solution, added the NUnit framework and started writing tests. It doesn't look the project is compiling at all before tests are run.

Running VS2015, latest update and latest version of ReSharper.

0
Comment actions Permalink

I'm seeing the same on VS2017 and the latest bits. Closing the session and reopening it helps refresh the code run.

0
Comment actions Permalink

The problem is still exists. Resharper 2019.1.1

0
Comment actions Permalink

Hello Emil!

 

Could you please specify what option is set in Unit Test session tab | "Options" combobox | Build Policy?

Thank you.

0
Comment actions Permalink

I tried with:

1. Automatic - the changed project not rebuild, and tests are not real. - NOT WORKING 

2. Automatic (Whole solution) - build all projects(losing to much time for that), but result is the same, tests are not real - NOT WORKING

3. Never build - This not usable for now for me

Only one way that I can using your expensive DotCover (Resharper Unit Tests) is - before start tests I manually make Right Mouse Click in my UnitTest Project and select "Rebuild". If I select just "Build" the tests are not real.

You can reproduce this error if you make two projects

1. Library  - method example: return 1+2;

2 . UniTest project who using class from the Library and expect result equal to 3

A. Whit out manually Rebuild solution do

  - Start unit test - really 1+2 is equal to 3, as expected

B. Change method in Library to return 2+2;

C Make again step "A".

   - you will see how your test say that 2+2 is equal to 3

 

Using "Automatic (Whole solution)" is stupid because I what now to test changed code, not all solution

You can send me your replay or if you need more information on my e-mail address.

 

Thanks for replay.

 

 

 

0
Comment actions Permalink

Hello Emil!

 

The option Auto should fit the case:  before executing tests, ReSharper rebuilds all projects that are related to the current test session and that have changes since the last execution.

I've just tried creating sample project that you've described and ReSharper automatically rebuilds changed library project and test provides correct result for changed code.

Possibly I'm missing something? Could you please provide your sample?

Thank you.

0
Comment actions Permalink

Намерих решение на проблема, колкото и да звучи глупав и безсмислен.

Инсталирах xunit.runner.visualstudio въпреки, че използвам NUnit. И не ми трябва xunit.

Ако ви интересува, ще постна линк към решението на проблема.

И се надявам скоро да оправите Resharper 2019.1.1 да не изисква xunit.runner.visualstudio за да компилира използваните библиотеки от UnitTest проекта.

Успех

1

Please sign in to leave a comment.