All ready to build your .NET MAUI app now? Be sure to check out this playlist which contains all my videos about .NET MAUI 😱 kzbin.info/www/bejne/iXybpmaDor2hoKc
@torbenschramme47222 жыл бұрын
Thanks for the video, Gerald! Great start into MAUI testing. I have two questions: 1) Is there any approach so far for MAUI UI testing (like Xamarin.UITest)? 2) When my MAUI project uses packages that don't support the bare net7.0 framework (e.g. the DevExpress libraries, they only support net7.0-androidxx + net7.0-ios, but not plain net7.0), then your presented approach is not possible; the project then even doesn't start compiling for net7.0, because of failed package restore. Any idea for that?
@АйбатАманбайұлы9 ай бұрын
any solutions?
@ProgrammingWithChris2 жыл бұрын
Oh, this is great, i literally put out a video yesterday where I talk through the troubles I had with Unit Testing in Maui, but this rocks, i also didn't know about the .dll solution. I'll say I got pretty close :). Thanks for the video!
@jfversluis2 жыл бұрын
Well glad you figured it out, time for that follow up video 😉
@wendellkelsey3562 жыл бұрын
Finally! Thank you! I could never find a way around the "Application does not have static Main method" build error. Tried for weeks. Even tried to sneak a completely blank static Main method into a file that served no other purpose, but that messed up the Maui entry point. Finally gave up on the entire idea of testing the app. It seems obvious now to put a simple conditional in the csproj file. I can't thank you enough for this...
@cynstrider4912 Жыл бұрын
I spent 2 hours trying to get the unit tests to work and after watching this video I got it working in a few minutes. Thank you!!!!
@jfversluis Жыл бұрын
Perfect! Good job!
@dotMorten2 жыл бұрын
Adding .net6 to the application project, instead of adding net6-windows to the unit test project seems backwards. Also that won't work if a dependency requires runtime libraries for a specific platform (like including native libraries). By being explicitly about the target framework in your unit test, you know exactly what you're testing, and for which platform (and no need for your output type hack either). You aren't even testing the actual binary that gets shipped in the app, but instead merely a separate class library you made just for the test.
@DonovanBrown Жыл бұрын
I went the other direction as well and got it to work. I just had to change the PlatformTarget to x64 in my test project. I did not have the change the original project file at all.
@johnjohnson26985 ай бұрын
@DonovanBrown do you have a way to share what you did?
@OrkwilPКүн бұрын
@@johnjohnson2698 In visual studio you can change the platform target from build > configuration manager
@nathandavis75932 жыл бұрын
Thanks Gerald! I believe if you clean your solution after making changes to the proj file. That should fix the build. The project.assests.json file has to be updated to include .net6 that was added to the target frameworks.
@jfversluis2 жыл бұрын
Ah that totally makes sense! Thanks for sharing!
@larryleach95402 жыл бұрын
Finally! I have my Xamarin unit tests back in action. Thanks!!
@jfversluis2 жыл бұрын
Nice job! Well done!
@johnjohnson26985 ай бұрын
You may have just saved my project! Thanks man
@jfversluis5 ай бұрын
Good luck my friend!
@anthonychambers4679 Жыл бұрын
Thanks Gerald, you solved my problem getting Maui NUnit tests to build
@jfversluis Жыл бұрын
Perfect! Thanks for letting me know!
@jeffm38652 жыл бұрын
Thanks. Before your video, I was bewildered while trying to get this to work. Very helpful.
@jfversluis2 жыл бұрын
Yeah it’s not really straightforward 😅 hope we can make that better in the near future!
@brunozimmermann40662 жыл бұрын
Many thanks, there is one small problem. As soon as you configure the mau app with the target net6.0, it is not possible to chose anything other then the local machine (windows in may case) as the target for the build. Every time I want to test I have to add and later remove the target net6.0 to the maui app project.
@jfversluis2 жыл бұрын
Make sure that you add the conditional attribute on the OutputType in your csproj file. See the sample code linked under the video.
@aalialikoski2 жыл бұрын
@@jfversluis I added the conditional attribute but still having the same problem. The tests work nicely, but I cannot debug the project at all using Android emulator :(
@aalialikoski2 жыл бұрын
Using VS 2022 Enterprise Version 17.3.6, the latest available currently
@ramarajthangapandi3424 Жыл бұрын
I have the same issue. As soon as I add the 'net7.0', I don't see the run (on Android/iOS) menu anymore. I have to remove it, in order to run my app
@ramarajthangapandi3424 Жыл бұрын
I added the .net7.0 in the last in my VS Mac. It worked. Like this net7.0-android;net7.0-ios;net7.0
@JayVeeDee2 жыл бұрын
Good stuff, I'm sure this will help others when setting up the project. This was something I just couldn't get to work for my project. I'm pretty new to MAUI and C#, so I had no idea how to change the .net6.0 to become a dll for the test project or I did not even know you could do that!
@jfversluis2 жыл бұрын
That's what I'm making these for 😉 glad you learned something!
@simonbrettschneider29102 жыл бұрын
Thank you for the tutorial - very helpful. How do you handle third-party packages such as the barcode scanner from ZXing.Net.Maui that does include net6.0? As soon as I compile the test project, the build will fail with "The type or namespace name 'ZXing' could not be found (are you missing a using directive or an assembly reference?)" which makes sense - any workaround?
@jfversluis2 жыл бұрын
I think ideally you'll want to have your code you want to unit test in a separate project so you don't run into this :)
@felicityrhone1866 Жыл бұрын
Right now I'm handling ZXing by adding a conditional so the package is only included for the platform (not plain .net7) target frameworks: 0.3.0-preview.1 0.3.0-preview.1 Then for the class that uses ZXing, I created a partial class (as described here stackoverflow.com/questions/73962418/maui-how-to-use-partial-classes-for-platform-specific-implementations-together?rq=1 ) to create a plain .net implementation that avoids ZXing while the platform-specific implementation can still use it.
@Richthofen802 жыл бұрын
Would like to see an example for acceptance testing / system testing via Xamarin UITest or the like.
@jfversluis2 жыл бұрын
Have a look at the release pipeline for a Xamarin.Forms release. It’s public 😉
@ericlobdell64849 ай бұрын
Ran into this exact issue yesterday, thanks!
@zippolag Жыл бұрын
I feel dumb for how long I spent trying to make this work but couldn't until I found this video! I'm going to steal the tip and post it on stack overflow ASAP :D ... TBH though, I think it's cleaner to just keep the "old" Xamarin-style approach of having a core project with just "net6.0" as target and so your UnitTest project dependency doesn't have to deal with the UI-specific MAUI bits.. Though if you create a "MAUI Library" project then you also get all of those extra output types for each platform, so I'll probably have to deal with that complexity _eventually_, but at least I don't have to keep slamming my head to the table just to get a boilerplate project to build.
@julybrown49162 жыл бұрын
Thanks Gerald. Appreciate your content.
@jfversluis2 жыл бұрын
Thanks you so much July!
@ayanbanerjee78162 жыл бұрын
Hi Gerald , I have followed all the steps you have mentioned but once i add net6.0 to properly group my unit test project get selected as a start-up project and i could not able to build the main project , I am using visual studio preview letest version
@jfversluis2 жыл бұрын
Can't you set the startup project back to the .NET MAUI app? :)
@ayanbanerjee78162 жыл бұрын
@@jfversluis No I can't setup back to MAUI project
@jfversluis2 жыл бұрын
Make sure you added the Condition attribute on the OutputType in your csproj
@ramarajthangapandi3424 Жыл бұрын
Same issue. The unit test project is set as the startup project, can't make the main project as the startup one. I have to remove the 'net7.0' target framework from the main project to see the run menu again. @Ayan Banerjee
@josedonizeteoliveirajunior17442 жыл бұрын
Can you believe youtube took my subscription? I liked the video a lot. please make a video for us teaching how to make a unit test code, or give us a reference to study. would be very appreciated
@jfversluis2 жыл бұрын
Thanks for the idea!
@FahadHassan-ki6xt Жыл бұрын
Thanks for the great content. I am facing a problem, when I add the project reference. I got error that some packages does not support .net 6.0
@xktsxl3gend2 жыл бұрын
i was able to do this early on from looking at the maui source code but still havent been able to figure out how to get it to build when there is platform specific code as well that doesnt have an implementation for targeting the net6.0 framework. any tips on that one would be helpful
@xktsxl3gend2 жыл бұрын
did some more work on this today and was able to get it to finally work with platform specific code defined as well so all good :-)
@jfversluis2 жыл бұрын
Awesome! Glad you figured it out, thanks for sharing! Do you have a repo or something that you can share?
@xktsxl3gend2 жыл бұрын
Unfortunately i can't share the repo but i could share/email the snippets/details of how i resolved it. Issue I'm running into now is that visual studio won't let me launch the Maui project now 😂😂. I created a new project just to see what the issue was and that one launched fine but was soon as I added the new project as a reference to the test project and added the net6.0 as a framework to it, it also wouldn't launch anymore until i undid those parts. So I'll have to figure out what's up with that as well
@xktsxl3gend2 жыл бұрын
got this resolved as well. had to unload the project and reload it.
@davidstrau3074 Жыл бұрын
Thank you so much! Very good tutorial.
@jfversluis Жыл бұрын
Thank you so much David! Appreciate it!
@jewersp2 жыл бұрын
Hi Gerald, I keep running into issues with both xUnit and NUnit here. With NUnit I cannot debug the app in any emulator at all and with xUnit I only managed to debug with Windows and Android (haven't tried iOS yet) after adding a separate DebugUnitTests Configuration to the solution and setting the $(TargetFrameworks) inside separate tags based on Condition="'$(Configuration)' == 'DebugUnitTests'". This is not ideal, but so far it's the only working way for me. Any ideas on this?
@jfversluis2 жыл бұрын
Not sure if I follow what you're doing.Check the sample code repo that is in. the video description which might help you.
@simonmardine64142 жыл бұрын
👏👏 as always super interesting 😁
@jfversluis2 жыл бұрын
Thanks so much Simon!
@enricoroselino7557 Жыл бұрын
so the test unit should be on other project ? i tought its gonna be like laravel or python on same project but inside Test folder, hmm but its make sense since the dev package not inside the real project
@jfversluis Жыл бұрын
If you really want to you could have it in the same project maybe? But to me that doesn't make much sense tbh :) at the very least its not the ".NET way"
@enricoroselino7557 Жыл бұрын
@@jfversluis yes, i am adapting to .NET, i agree after second tought testing doesnt need to be in the same project 😁 trying to get rid of my imagination driven development
@Steven-hq6df2 жыл бұрын
I'm using net7.0 with Visual Studio 17.4.0 Preview 2.1, and my project.assets.json says "Unable to read project information for 'Project': Sequence contains more than one element". I think this is an issue with Visual Studio Preview because when I remove net7.0 it restores and builds perfectly fine.
@Steven-hq6df2 жыл бұрын
Created issue #10579 to report it
@henriksndergaard26992 жыл бұрын
I found your channel while looking for someone with experience developing c# on a mac and found your M1 video from a while ago. I got a new job starting in september and I am to pick a laptop for that. I really love mac's but am developing in windows. Do you use your mac for programming or do you use it for something else now? And if you use it for coding do you run arm windows through parallels or other solutions?
@jfversluis2 жыл бұрын
I am using my Mac with Visual Studio for Mac and I can do everything I want with that. I don't run Windows virtually, so can't help you with that, sorry!
@henriksndergaard26992 жыл бұрын
@@jfversluis thanks. You answered my question perfectly
@thomasgalliker Жыл бұрын
Can I somehow include a new folder "net" inside the "Platforms" folder in which I have all the net7.0 related code? That would be awesome. Unfortunetly it didn't work even after hours of trying.
@jfversluis Жыл бұрын
Probably do something like this learn.microsoft.com/dotnet/maui/platform-integration/configure-multi-targeting#configure-folder-based-multi-targeting
2 жыл бұрын
Hi Gerald, thanks for this video. Is there a way to manage multitargeting code for .net6.0 target like we do with android and windows in sub app directories Platforms/Android/.... ? Thanks
@jfversluis2 жыл бұрын
I'm not sure what you mean... If you go into Visual Studio and do File > New > .NET MAUI Class Library you will get the template with the different folders for the different targets, is that what you mean?
@andreagavioli73312 жыл бұрын
Thanks Gerald! Useful video as always. I have a question: what about testing Android and iOS both unit and UI tests on .NET MAUI? Thanks in advance.
@jfversluis2 жыл бұрын
Running these on iOS and Android, you should check out this: www.nuget.org/packages/Shiny.Xunit.Runners.Maui/1.0.0-alpha-0008 UI Tests isn't available yet unfortunately.
@usz14445 ай бұрын
it is still needed and works in .net 8
@jfversluis5 ай бұрын
Thanks for letting us know!
@frankpohl56202 жыл бұрын
Hello gerald, this worked fine until I added some platform specfic code to the project. Now the compiler complains that I do not have a partial implementation for net6.0. The error message is "Partial method 'a method name' must have an implementation part because it has accessibility modifiers." How can I avoid this ? Or how can I tell the compiler that the Windows platform is also the platform that implements the net6.0 code?
@jfversluis2 жыл бұрын
If you do this you will have to implement it for all platforms, even if they are empty.
@franksprototypes99632 жыл бұрын
@@jfversluis My problem is not, that I do not have partial implementations. I have partial implementations in the folders Windows, iOS and Android. But I do not have a folder for the target platform net6.0 and I do not know how to match a targtet platform to a folder. Looks like like "net6.0-android" is magically connected to the folder "Android" and "net6.0- iOS" to "iOS". But in which folder do I have to implement the platform specific code for the target "net6.0" that you introduced for the unit test?
@jfversluis2 жыл бұрын
@@franksprototypes9963 Right! In that case have a look at this: learn.microsoft.com/dotnet/maui/platform-integration/configure-multi-targeting Configure a target for the net6.0 code. You'll probably see an example in the .NET MAUI Community Toolkit or my Plugin.Maui.Audio
@alexnikolayev74092 жыл бұрын
What if I have a .NET6-Android/iOS project? Not MAUI. I can't get this to work following the same steps. Adding the .NET6.0 target just makes my main project fail to compile because it does not recognize the Android/iOS types.
@jfversluis2 жыл бұрын
Do you have an example somewhere?
@Robinbura2 жыл бұрын
Hi, Gerald, thanks...you doing the awesome job. One request why don't you make an video on background task in .net maui.....
@jfversluis2 жыл бұрын
Because it’s a hard topic! 😄 you might want to have a look at the Shiny plug-in!
@pushanroychowdhury57412 жыл бұрын
Thanks a lot for this !!!
@jfversluis2 жыл бұрын
You’re most welcome! Now go write those tests 😉
@timokeller47502 жыл бұрын
Hello Gerald, first of all thank you for your videos, they are really great. Also the video here about unit testing is very good. But our team would also like to do UI testing, so far we have done that with the Xamarin UI testing framework. Is there any way or do you have any idea how to do that with .NET Maui? Thanks a lot. Timo
@jfversluis2 жыл бұрын
Hey Timo, thank you so much! UI testing is still being made compatible, so it doesn't work right now. It will come though, hopefully soon!
@cleberrangeljr2 жыл бұрын
Hey guys, do we have any control libraries for MAUI like MahApps or similar?
@jfversluis2 жыл бұрын
Have a look at GrialKit, SyncFusion, Telerik, DevExpress… and probably more!
@cleberrangeljr2 жыл бұрын
@@jfversluis thanks Gerald, I’m kinda leaning towards open source our free ones! 😄 I found these, but they all are paid…
@jfversluis2 жыл бұрын
@@cleberrangeljr SyncFusion is free under certain conditions. Look for community license
@xDeew8 ай бұрын
Gracias amigo, me salvaste de una!
@jfversluis8 ай бұрын
Glad to hear that!
@ismaelsanchez31642 жыл бұрын
Hi Gerald, I followed all your steps with a brand new project and it builds correctly, but when trying to launch the app in Android I get now an alert screen 'Unable to start debugging. The startup project cannot be launched... additionally make sure its debug settings are correctly configured in project properties' I use VS 17.3.0 Preview 3.0 Community edition.
@joanox2 жыл бұрын
That is the exact same error i am getting now. Any idea how to fix it Gerald?
@jfversluis2 жыл бұрын
If you can get me a reproduction I can have a look!
@joanox2 жыл бұрын
@@jfversluis Any idea how to send you the link to my github profile, youtube won`t let be paste any link to github
@jewersp2 жыл бұрын
I have the same issue, but I managed to work around it. For now, I've added a separate Solution Configuration that I called "DebugUnitTests" incl. additional Project Configurations of the same name. Then I've changed the .csproj file of the main project like this: net6.0-android;net6.0-ios;net6.0-maccatalyst net6.0;net6.0-android;net6.0-ios;net6.0-maccatalyst Unfortunately, for this to work it's necessary to reload all projects after switching between the Configurations.
@davidmccollough47912 жыл бұрын
Thanks, awesome video
@jfversluis2 жыл бұрын
Thank you David!
@ericbressant91632 жыл бұрын
Nice but it seems that it does not work for me on the Application project... and I event not manage to open the sample VS2022 feeze each time I try. 😞 On my project I do modification of csproj of the app like in video. it complain that I can't put net6.0 in TargetFrameworks node... Does anyone have the same trouble ?
@jfversluis2 жыл бұрын
If things freeze etc. something else seems wrong, that shouldn't happen
@ericbressant91632 жыл бұрын
Hi @@jfversluis thx to answer. yeah, it happens on the moment I add net6.0 on project file. I am using the last VS preview version maybe it's that. Even your sample code freeze vs on opening
@mohammedalsabahii22 жыл бұрын
Can i use xUnit with maui android app or ios ? , thank you for this great content
@jfversluis2 жыл бұрын
Yep, check out this: www.nuget.org/packages/Shiny.Xunit.Runners.Maui/1.0.0-alpha-0008
@martinhonnen92592 жыл бұрын
Is there any way to unit test .NET 6 code on Android?
@jfversluis2 жыл бұрын
Yep! You might want to have a look at this: www.nuget.org/packages/Shiny.Xunit.Runners.Maui/1.0.0-alpha-0008
@manuelmair1855 Жыл бұрын
This solution does not work with NET7.0. Do you have a solution here as well
@jfversluis Жыл бұрын
Change what I show in the video to add net7.0 instead of net6.0 and it should work
@manuelmair1855 Жыл бұрын
@@jfversluis OK, i solved the problem. The file path was too long. I put the project in an other dictionary, now everything works as it should!
@yanaraldaghestani63052 жыл бұрын
thanks man
@jfversluis2 жыл бұрын
Happy to help!
@АйбатАманбайұлы9 ай бұрын
awesome!!!
@yousifarshak2 жыл бұрын
Good work
@jfversluis2 жыл бұрын
Thank you Yousif!
@web777master Жыл бұрын
Can I give you a few likes? That's what I needed. Awesome!