Note: Answering my own problem for future developers.
I right click a Method > Create Intelli Tests.
I choose the MSTestv2, chose the Project.Test project, click OK and see the following output:
Processing Proj.API
Scanning assembly references in Proj.API Applying
template AssemblyInfo to Proj.API Applying template Tests to Proj.API
test stubbing ProductController -> ProductControllerIntelliTest
generating method bodies
flushing generated code
Unfortunately the Test.cs file is NOT created.
I've set all projects x86 and that doesn't make a difference.
Does anyone know why this doesn't work?
For some reason I had to specify a New Project for the Intelli Tests.
Creating new IntelliTests in the new project work, however they cant be added to the standard Test Project.
Hopefully someone else knows why.
Related
I used to see "Run Test | Debug Test" links top of every test function in VS Code for Go. But they are missing now. How can I re-enable them?
This picture shows what I am talking about:
Check your options to confirm that the Go test explorer is enabled:
Preferences > Settings > User Settings > find "go test enable code lens"
Taken directly from the go.dev doc for the testing package
To write a new test suite, create a file whose name ends _test.go that contains the TestXxx functions as described here. Put the file in the same package as the one being tested.
Please ensure that your test file name ends in _test.go, and that the function you're trying to test starts with Test (like it does in your snippet).
Had the same issue today. In my case opening the Command Palette (Ctrl+Shift+P) and running "OmniSharp: Restart OmniSharp" fixed it.
Same thing here - simply closed down VS Code and opened it back up again... they all appeared once more.
This happened to me, though I was writing Javascript (not Go).
To fix that, I need to make sure the Es6 import & export statements are correct (-- correctly importing the correct item from the correct file path),, -- for this current test js file & relevant imported js files (or even all files in current project).
(Then you must save the test js file to refresh it.)
The Test Explorer's Output panel may(?<) throw an Error to indicate that.
I have this situation when there are many folders in the project I opened in VScode. But these options appear only when I open the folder containing the script I want to run the test in in a new window in VSCode. I don't know why, it's weird.
I have been working on a extension for Visual Studio Code (v1.15.0). It contains commands (functions) to change HTML code in the VSCode editor window, for code conversion purposes.
I decided to extend my unit test code with an test-data.html file. So the test are running on a prepared HTML document, to test the commands and results.
My launch.json file, contains something like
... "args": ["${workspaceRoot}/test/test-data.html", "--extensionDevelopmentPath=${workspaceRoot}", "--extensionTestsPath=${workspaceRoot}/out/test" ], ...
Everything works fine, except for the fact that after the test (with tested code changes), the test file is saved. Ruin the original test data set.
I would like to disable the auto save in the 'Extension Development Host' environment, when my test are run. Can we do that or maybe, introduce a couple of undoes?
Or create a copy in the ./out folder and use that? Then how to do that.
Aug. 18, additional note
It's a strange problem. I'm working on this project at home and at work. Different machines. VSC is same version, maybe different extensions.
This problem of compromising my original test data, occurs only when working at Home. On the work PC everything works as expected, test data stays as it is.
Maybe something like 'auto save', I need to investigate.
Sep. 8, additional note
Nailed it, it was the 'Auto Save' option turned on. Not sure why it was set. Problem solved (I also implemented a copy function, which solved the problem also).
Use fs-extra to copy your test-data.html file to the out folder and then use the same command you used to load it, just change /test to /out.
I'm trying to create a self-hosted WebAPI 2.0 project that allows you to open/explore/build .sln solutions through an API.
Here's the code within one of my controllers, that's supposed to return a list of projects given a path to the .sln:
public async Task<IHttpActionResult> GetProjects(string slnPath = "")
{
var workspace = MSBuildWorkspace.Create();
var solution = await workspace.OpenSolutionAsync(slnPath);
var projects = solution.Projects;
}
I would expect projects to hold the projects in the solution, but according to the debugger, solution.Projects and solution.ProjectIds always seem to be empty.
I've tried this with multiple .sln files, all of which I can open in Visual Studio and see that they have projects in them.
I've seen this question, but my project isn't a Visual Studio add in, it's a class library called from a command line application.
This is generally caused by one of a few things, in order of commonality:
You are missing copies of Microsoft.CodeAnalysis.CSharp.Workspaces.dll or Microsoft.CodeAnalysis.VisualBasic.Workspaces.dll. Make sure when you are running your project that those DLLs are next to the main Microsoft.CodeAnalysis.Workspaces.dll.
You're loading solutions with project types we don't support. We should support any project type except the project-less Web Site projects. Class libraries should work just fine.
We have a bug that's causing us to mis-handle your particular project types. If that's the case, file a bug on GitHub.
If you are getting this issue in unit tests but not in your production code, ensure that you have referenced both Microsoft.CodeAnalysis.CSharp.dll and Microsoft.CodeAnalysis.CSharp.Workspaces in your test project.
JYL mentioned it in the comments of the selected answer but I didnt see it right away.
We have a solution in TFS 2012 that contains several projects. I have set up a Continuous Integration build on our build server and have set Clean Workspace = None. I'm using the TFS Versioning template 2.0 to update the AssemblyFileVersion and AssemblyVersions.
When the build is run, each project has its AssemblyInfo.cs file updated with a new version number even though there have been no changes made to the code in some of the projects. Ideally we want the version to change only if there have been changes to the project.
I was considering building each project separately, but we would prefer to be able to simply build the solution. I have read that Clean Workspace = None should prevent the projects from being updated but it doesn't appear to be happening for me since the timestamp on all the dll's are showing as changed after the build.
I am new to setting up a build process, so I'm hoping there is something simple that I'm doing wrong. Any suggestions would be greatly appreciated.
Update:
After checking the suggested link, it appears that I'm doing two things during build that may be causing the issue: 1) web.config file transforms that take place in an "AfterBuild" step in one of my projects and 2) using the version number increment features in the "TFS Versioning" template without opening up the workflow to see how it is checking for changed files. I'll remove both of these and see what happens.
This is a good question and it is possible. I run powershell scripts that use the TFS API to determine what files have changed
You need to get the changesets and shelvesets also, but once you have these you can get the information you want like this:
function Get-ChangesetChanges()
{
[CmdletBinding()]
param ([Parameter(Mandatory=$true)][string]$Changeset,[Parameter(Mandatory=$true)][string]$TFSServer)
[void][Reflection.Assembly]::LoadWithPartialName('Microsoft.TeamFoundation.VersionControl.Client')
[void][Reflection.Assembly]::LoadWithPartialName('Microsoft.TeamFoundation.Client')
$tfs = [Microsoft.TeamFoundation.Client.TeamFoundationServerFactory]::GetServer($TFSServer)
$vcs = $tfs.GetService([Microsoft.TeamFoundation.VersionControl.Client.VersionControlServer])
$vcsChanges = $vcs.GetChangeset($changeset).Changes;
$changes = #();
foreach ($change in $vcsChanges)
{
$changes += $change.Item.ServerItem;
}
$changes;
}
Things were running fine. Who knows what changed, but now I end up with:
Unit Test Runner failed to load test assembly:
JetBrains.Resharper.TaskRunnerFramework.TaskException:Exception of type 'Microsoft.VisualStudio.TestTools.CommandLine.CommandLineParameterException' was thrown.
Any suggestions?
I've just been having the same problem. It turned out that the Solution Items "folder" had a couple of .testsettings files in it which didn't actually exist (probably because they weren't added to the Git repo). Anyway, I removed them from the Solution and the R# runner now works fine.
Hope that helps.
You can check here for R# bugs that have the same description and maybe find the cause of your problem or a possible workaround. This bug seems to come close.
The other answers did not work for me unfortunately, instead I had to create a testsettings file manually to resolve the issue:
Right click Solution root
Add > New Item...
Select Test Settings from the Installed Templates column
Select the Test Settings item, and rename to the desired file name as necessary
Add
You should now be able to run your unit tests correctly.