Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Howto run test in VS Code? #690

Open
Arthurvdv opened this issue Jul 9, 2024 · 9 comments
Open

Howto run test in VS Code? #690

Arthurvdv opened this issue Jul 9, 2024 · 9 comments
Labels
documentation Improvements or additions to documentation

Comments

@Arthurvdv
Copy link
Collaborator

image

I'm probably missing something obvious, but how do I execute the test automation in VS Code? Or do I need to install an additional Test extension?

I've created an clean Windows VM with VS Code version v1.91.0 and these installed extensions

  • ms-dotnettools.csdevkit@1.7.27
  • ms-dotnettools.csharp@2.34.12
  • ms-dotnettools.vscode-dotnet-runtime@2.0.8
  • ms-dynamics-smb.al@13.1.1065068

I'm also looking into integrating the test in the pipeline of GitHub, running the tests from the command line doesn't return the expected results.

image

dotnet test /p:FeatureFlags=#ManifestHelper

  Determining projects to restore...
  All projects are up-to-date for restore.
  BusinessCentral.LinterCop -> C:\DEMO\BusinessCentral.LinterCop\BusinessCentral.LinterCop\bin\Debug\netstandard2.1\BusinessCentral.LinterCop.dll
  BusinessCentral.LinterCop.Test -> C:\DEMO\BusinessCentral.LinterCop\BusinessCentral.LinterCop.Test\bin\Debug\net8.0\BusinessCentral.LinterCop.Test.dll
Test run for C:\DEMO\BusinessCentral.LinterCop\BusinessCentral.LinterCop.Test\bin\Debug\net8.0\BusinessCentral.LinterCop.Test.dll (.NETCoreApp,Version=v8.0)
Microsoft (R) Test Execution Command Line Tool Version 17.10.0 (x64)
Copyright (c) Microsoft Corporation.  All rights reserved.

Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
No test is available in C:\DEMO\BusinessCentral.LinterCop\BusinessCentral.LinterCop.Test\bin\Debug\net8.0\BusinessCentral.LinterCop.Test.dll. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again.

@christophstuber Can you share your setup or do you see anything I'm missing here?

@dannoe
Copy link
Contributor

dannoe commented Jul 9, 2024

Currently the references inside the test project are added with the private attribute set to False. So they won't be copied to the bin folder of the test project and the tests fail (but not very visible)

dotnet test doesn't display anything. Rider displays some cryptic messages, and Visual Studio did something similar.

I already commented on the pull request to ask this question (see #648 (comment)). But since it's already merged, christophstuber may not have noticed.

<Reference Include="Microsoft.Dynamics.Nav.CodeAnalysis">
    <SpecificVersion>False</SpecificVersion>
    <HintPath>../ALLanguage/extension/bin/Analyzers/Microsoft.Dynamics.Nav.CodeAnalysis.dll</HintPath>
    <Private>False</Private> <!-- should be True, but I am not sure if this was maybe intentional -->
</Reference>

Maybe we can set it to true, until christophstuber gets back to us.

@Arthurvdv
Copy link
Collaborator Author

@dannoe , awesome! That was indeed the difference it seems and now I see the options to run tests as I would expect 🥳

I'll await the feedback of christophstuber before changing these properties in the repo.

image

Last hurdle is to apply the FeatureFlags on executing a test, I'll have a look into that tomorrow.

@christophstuber
Copy link
Contributor

@dannoe Thank you for figuring that out. I'm sorry for being inactive for some time, but I'm currently on a business trip.

@Arthurvdv Arthurvdv added the documentation Improvements or additions to documentation label Jul 12, 2024
@dannoe
Copy link
Contributor

dannoe commented Jul 13, 2024

@christophstuber I have another use case for your fork of the RoslyTestKit. Would you be okay with me putting your code into its own repository and releasing a nuget package for it?

@christophstuber
Copy link
Contributor

Created #702 to remove the private false property from the project.

@dannoe Feel free to do so, as long as it remains accessible to everyone. Also maybe mention https://github.com/cezarypiatek/RoslynTestKit as the original source.

@Arthurvdv
Copy link
Collaborator Author

I could use some help getting the tests to run manually in VS Code.
Probably it's something simple, but somehow I can't find the right solution 🤔

image

When executing the 'play' button it runs the command dotnet build C:\Users\arthur.vandevondervo\repo\BusinessCentral.LinterCop\BusinessCentral.LinterCop.Test\BusinessCentral.LinterCop.Test.csproj /property:GenerateFullPaths=true /consoleloggerparameters:NoSummary /p:Configuration=Debug /p:Platform="AnyCPU"

Where I somehow want to add an extra parameter for handling the preprocessor directives; /p:FeatureFlags=#Spring2018#Fall2018#Spring2019#Fall2019#Spring2020#Fall2020#Spring2021#Fall2021#Spring2022#Spring2022RV1#Spring2022RV2#Fall2022#Spring2023#Fall2023#Fall2023RV1#Fall2023RV2#Fall2023RV3#Spring2024#Fall2024#Spring2024OrGreater#ManifestHelper#PageSystemAction

Any help on this is appreciated

@dannoe
Copy link
Contributor

dannoe commented Jul 16, 2024

As I don't use vscode for C# I can't really help here.

@christophstuber
Copy link
Contributor

What works for me in VS Code is running dotnet test /p:FeatureFlags=#Spring2018#Fall2018#Spring2019#Fall2019#Spring2020#Fall2020#Spring2021#Fall2021#Spring2022#Spring2022RV1#Spring2022RV2#Fall2022#Spring2023#Fall2023#Fall2023RV1#Fall2023RV2#Fall2023RV3#Spring2024#Fall2024#Spring2024OrGreater#ManifestHelper#PageSystemAction from the terminal.

@Arthurvdv
Copy link
Collaborator Author

@dannoe and @christophstuber, thank both of you for the quick response!

The command-line approach indeed works 🤗 I was hoping to have it working with the gui and with debugging functionality, but that will be for somewhere in the future I guess.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

3 participants