Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Using NCrunch to test Blazor WASM using BUnit
maluedev
#1 Posted : Friday, May 12, 2023 11:27:16 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 5/12/2023(UTC)
Posts: 5
Location: United Kingdom

Was thanked: 1 time(s) in 1 post(s)
I'm building tests into a Blazor WASM project (it's TDD but that's irrelevant to this issue).

I ran into a problem where the test target Component in the production code in the main project cannot be found from the test project when the dependency is expressed as dependant Project. However, when i make a direct reference to the assembly containing the target component.

I have prepared a project here ==> https://github.com/jimde...tBunitTestingCompoennts which shows the problem.

The project is setup to show the working scenario. To show it non-working remove the reference to the assembly and replace it with a reference to the project.

Thanks

Jim Deane
Remco
#2 Posted : Friday, May 12, 2023 11:05:54 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,144

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Hi Jim,

Thanks for sharing this issue.

For some reason, the sample project link doesn't seem to work for me. Are you still experiencing the problem?

Do the main project and the test project both build to the same version of .NET?
jdeane
#3 Posted : Saturday, May 13, 2023 3:35:51 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 2/13/2015(UTC)
Posts: 3
Location: South Africa

Hi Remco. Yes, I’ve also gone through this with my lead dev and he confirmed the problem. Definitely both projects on .Net 7

Apologies, I had somehow made the repo private 😵‍💫 you should be able to access it now.

Thanks

Jim
Remco
#4 Posted : Monday, May 15, 2023 12:42:27 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,144

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Hi Jim,

Thanks for opening up the sample project. I'm not sure if the sample project is fully representative of the project you're working in, but the source of the problem appears to be in your NCrunch configuration.

The primary project has the 'Ignore this project completely' configuration setting enabled. When this is turned on, NCrunch will avoid loading the project and any other project that depends on it will fail to build.

On deactivating this setting, the solution built successfully for me and all warnings were cleared. Does this match things on your side?
maluedev
#5 Posted : Monday, May 15, 2023 10:12:54 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 5/12/2023(UTC)
Posts: 5
Location: United Kingdom

Was thanked: 1 time(s) in 1 post(s)
oh dear, this must be something a bit more subtle :(

I first thought i was being an idiot, and immediately set the ignore flag to false, changed to the project dependency and....

still broken :(

I have pushed the broken version to the repository and attached a screen shot (in the root of the Test folder) of the state as it appears when I have that version cloned from the repo (I cleared everything and cloned the repo as it is in GitHub just to make sure).

screenshot

Sorry if I'm still being an idiot!



By the way, the reason I set the ignore completely on the one project was that it was showing a build failure:

NCrunch: If you are experiencing problems in getting this project to build, have a look at http://www.ncrunch.net/d...ng_project-build-issues
..\..\..\..\..\..\..\Program Files\dotnet\packs\Microsoft.NET.Runtime.WebAssembly.Sdk\7.0.5\Sdk\WasmApp.targets (216, 5): $(MicrosoftNetCoreAppRuntimePackDir)='', and cannot find %(ResolvedRuntimePack.PackageDirectory)=. One of these need to be set to a valid path

which obviously isn't affecting the non NCrunch build.
maluedev
#6 Posted : Monday, May 15, 2023 11:23:24 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 5/12/2023(UTC)
Posts: 5
Location: United Kingdom

Was thanked: 1 time(s) in 1 post(s)
Turns out I'm the idiot. The build error wass the problem all along and you had solved it with "IsWasmProject = False"

Apologies for that


(Isn't it a bit odd to say FALSE here when it is a WASM project????)

Jim
maluedev
#7 Posted : Monday, May 15, 2023 1:15:22 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 5/12/2023(UTC)
Posts: 5
Location: United Kingdom

Was thanked: 1 time(s) in 1 post(s)
Except that.....

When I've applied the corrective actions to the original project, I still get the build problem.

I have therefore exposed the project repo to you at: repo

I have also placed a screenshot of the current state in the root of the test directory.

Sorry for being a pian but we are getting ready for showing the wonders of NCrunch to the team and we really wanted to do it with this new website example we are working on as we are using Blazor throughout our new software development.

Many thanks

Jim Deane
maluedev
#8 Posted : Monday, May 15, 2023 8:21:50 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 5/12/2023(UTC)
Posts: 5
Location: United Kingdom

Was thanked: 1 time(s) in 1 post(s)
Turns out it must have been some strange case of the way in which the project had grown.

I Built a new project from scratch, added back in all my source files and test files and everything worked correctly (with the 'IsWasmProject = False')


Thanks for looking into it

Jim Deane
1 user thanked maluedev for this useful post.
Remco on 5/15/2023(UTC)
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAF | YAF © 2003-2011, Yet Another Forum.NET
This page was generated in 0.054 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download