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.
Please sign in to leave a comment.
Hello
On Unit Test session tab, there is a "Options" combobox | Open it | Build Policy | Select needed option.
Thanks!
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.
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.
I'm seeing the same on VS2017 and the latest bits. Closing the session and reopening it helps refresh the code run.
The problem is still exists. Resharper 2019.1.1
Hello Emil!
Could you please specify what option is set in Unit Test session tab | "Options" combobox | Build Policy?
Thank you.
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.
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.
Намерих решение на проблема, колкото и да звучи глупав и безсмислен.
Инсталирах xunit.runner.visualstudio въпреки, че използвам NUnit. И не ми трябва xunit.
Ако ви интересува, ще постна линк към решението на проблема.
И се надявам скоро да оправите Resharper 2019.1.1 да не изисква xunit.runner.visualstudio за да компилира използваните библиотеки от UnitTest проекта.
Успех
This is still occurring with VS 2019 (v16.11.5) and R# 2021.2 (build on 2021-10-06).
.NET Target: net5.0
The R# test runner is not reliably recompiling changes, especially when they are made in referenced assemblies. R# seems to intermittently recompile, but not reliably. The only way I've found to get the tests to use the changes in another assembly is a complete clean/build.
R# Test Runner Build Policy is set to "Automatic".
One of my referenced assemblies is internal and decorated with the "InternalsVisibleTo" attribute, referencing the test assembly. Likely not germane to the problem, but thought I'd throw it out there.
Hello nCubed nCubed,
Could you please create a new support request and attach ReSharper log, to collect it please start VS with the following command:
and reproduce the issue. resharper_log is the needed file.
Thank you in advance.