In VS 2010, I could right click a method and have MSTest create a unit test for me. Where is this feature in VS2012 pro?
The command is still there. go to Tools->Options->Environment->Keyboard. Search the shortcuts for createunittests. The appropriate command comes up in the dialog box. simply assign it a keyboard shortcut and its ready to go. Works exactly like the VS2010 once you use the shortcut you created.
Just ran into this myself just now. Here is the explanation:
http://connect.microsoft.com/VisualStudio/feedback/details/748493/missing-funtionality-of-creating-a-new-unit-test-from-editor
"The 'New Test' menu does not have any extension points where 3rd party adapters can plug-in. Therefore we decided to remove it. We moved all the New Test Project types into the File -> New -> Project dialog."
So it seems it was removed because it was made for MSTest only, and now they support several frameworks out of the box. But I still miss it as well... Should be able to default to MSTest och NUnit...
Should select Add not New item in FILE menu to add a Test project into current solution.
below steps are copied from Walkthrough: Creating and running unit tests for managed code
To create a unit test project:
On the File menu, choose Add, and then choose New Project ....
In the New Project dialog box, expand Installed, expand Visual C#,
and then choose Test.
From the list of templates, select Unit Test Project.
Hope it helpful.
Related
I'm trying to generate a ShimDirectory (from System.IO.Directory). In the test project references I right click on System and select Add Fakes Assembly. This creates mscorlib.fakes and System.fakes in the Fakes folder.
However, the namespace System.IO.Fakes contains only six class (all Stub...) and no ShimDirectory, or any other shims I would expect.
Any ideas?
(Using VS2017)
Okay - turns out the trick is to restart Visual Studio, delete the fakes and regenerate them and it works!
Historical context:
We have a project consisting of following parts:
Host application (C++)
Scripting Engine library (also written in C++)
A lot of C++ plugins (around 30+)
A lot of scripts that tie all the stuff together...
From version to version some plugins are added and some are removed.
Till now we used Visual Studio solution (*.sln) to contain all the projects (*.vcxproj) for Host application, Scripting Engine library and plugins (one *.vcxproj per plugin!).
To share sources/projects we use proprietary source control system, and till now once we merged updates from the server (some plugin projects are added and some plugin projects are removed) all the project tree in the VS were refreshed thanks to "reload" feature (no action was required from developer to see and build updated source tree).
The problem:
Now our senior management decided to switch to Eclipse CDT/MinGW pair and we faced the issue that Eclipse Workspace is not the same thing as Visual Studio *.sln ...
Now when some plugin project folder appears or some plugin project folders disappears corresponding workspace items do not update accordingly.
Thus from now every developer has to use File>Import...>General>"Existing projects into workspace" File/"Open Projects from File System" to add new projects to own Workspace manually once they were added by other developer to the source control.
Also one has to manually remove from own Workspace those plugin projects that were deleted from source control...
This is a great contrast with what we previously had with Visual Studio where "reload" feature automatically updated project/source tree (just bacause all the information arrived with *.sln/*.vcxproj from server).
Our first option was to place Workspace\.metadata etc stuff to source control (as we previously did for *.sln files) but "that is not the way how Eclipse Workspace is designed to be used" (this is even not possible just because paths in .metadata\* are absolute and tons of Workspace\* stuff it is not mergeable at all)
Question:
Is there some way to automatically syncronize Eclipse CDT Workspace with project set obtained from source control. Like just press some (hidden?) magic "refresh" button (in special plugin to install or something like that) and all the new projects will be automatically added to the source tree in the Workspace and deleted projects will also disappear automatically, wothout need to use all those "Import" wizards, and withot need to remove deleted projects manually?
May be there is a special "Container" project type in Eclipse to play the same role as *.sln did in Visual Studio or something like that?
May be other options available?... Overall intention is not in replacing *.sln by some Eclipse equivalent but to support similar workflow when bunch of plugin projects is managed as a whole and project set "refresh" to be simple operation that does not require from each person in the team to manually track projects appeared/disappeared in that set.
Have you looked at using CMake to generate the Eclipse project files? You can then import those into an Eclipse workspace.
Its not automatic, but if you create separate CMakeLists.txt files for each part, then you can easily comment the include of that part in the main CMakeLists.txt file and regenerate the project files when you only want to load subset of the project.
https://cmake.org/Wiki/Eclipse_CDT4_Generator
Should you ever want to change back to VS or to another IDE CMake can generate project files for that too.
I've personally only used CMake to generate VS-solutions and Unix make files so I can't vouch for how well this works.
HTH.
On side note, why did management decide that Eclipse should be used instead of Visual Studio? It sounds like a poor decision without factual grounds or impact research prior to the decision being made.
Was it because Eclipse is free? Did they consider what reduced developer productivity costs?
Simply put:
In eclipse how do I run a shell/batch script when I build? I have an external tool that can be run by hand but I want to trigger it when the project is built. Using build variables in the script would be an added bonus.
Why I want this:
I work on multi-platform games for mobile. The teams in the company I'm at use X-Code, Visual Studio, and Eclipse (Momentics) for our games. We want to be able to pick up a phone and see overlay on-top of it with information such as who built it, when it was built, what branch and revision it's from, and what library versions are being used. I've done this with X-Code by running a script on build that dumps some of that information to the resource directory of my game that I can then parse at runtime. It's really simple and I'm up for alternate suggestions if you have them; keeping in mind it must work for the three IDE's our developers use.
Bonus Sugar:
In X-Code we can use build variables which would be super nice to have for eclipse as well. I use them to change to the active cocos2d-x repository and get a git log to tell us when the last commit to that repository was made and by who. If that isn't possible in eclipse I can figure something out.
Thanks in advance!
Add a custom builder to your project: open Project properties from the popup menu, on the builders page add a new Program. That will open a "External tool configuration" page.
There you can define a script to run, and also add parameters, where you can add Eclipse variables, such as ${workspace}, etc.
Be careful though: this will run every time when the incremental project builder runs, and the configuration is shared through version control (so beware of absolute paths).
I am new to using IntelliJ. I have only one grievance and that's the compiler. I prefer the way the Eclipse compiler will compile a project and skip classes with errors in them.
This is particularly a problem for if I want to write a unit test for a method I have to fix all errors in the entire project for running a single unit test!
You might say fix your project but I'm working on a project where people have already committed code with errors in it. How can I get around this, I saw there's an option to use the Eclipse compiler in the settings but this has made no difference/I don't know the argument to skip errors.
This fixed it for me on IntelliJ 14:
In Preferences->Build,Exec,Deploy->Compiler->Java Compiler, choose Eclipse compiler. Then check "Proceed on errors", which will appear once you choose the Eclipse compiler.
Then in Run->Edit Configurations expand the Defaults section on the left. Choose the configuration for your unit test framework (eg, JUnit or TestNG).
Then in the "Before launch" section, remove "Make" and add "Make, no error check"
Finally, you may need to delete any existing unit test run configurations so the new launch setting will take effect.
Not sure if this will be effective for what you're attempting to do and how your project is structured, but it worked perfectly well for me in my particular case, in that if your class has a main method, you can right click inside of the actual main method code and select "Run 'classname.main()'" from there.
This worked for me, but obviously may not be identical to your situation.
I got this from another answer located here: Intellij IDEA how to run a class not the entire project?
On IntelliJ 2018.1.4 (Linux): 2018-06-06
In File->Settings->Build,Exec,Deploy->Compiler->Java Compiler, choose Eclipse compiler from drop down. Option "Proceed on errors" should already checked (if not, mark tick on it), which will appear once you choose the Eclipse compiler.
Then in Run->Edit Configurations -> expand the Defaults section on the left. Choose the configuration for your unit test framework (eg, JUnit or TestNG).
Then in the "Before launch: Build,Activate tool window" section(see in end), remove "Build" and add "Build, no error check". Click apply and okay
Finally, you may need to delete any existing unit test run configurations so the new launch setting will take effect. This can be find from Run->Edit Configurations under (eg, JUnit or TestNG). or we can edit it
A clumsy way is to create a new module under your project file and make a test file in src folder of this new module
I have a vsprops file that defines the optimizations all of our projects should be built with for Visual Studio 2008. If I set the properties for the project to "inherit from parent of project defaults" it works, and fills them in the vcproj file. However, this doesn't protect me from a developer checking in a project file that changes the optimizations. In this case, the project settings are used over the vsprops settings. I need to make it so that vsprops always takes precedence over what is in the vcproj file. Is this possible? Other workarounds are also welcome.
Hmya, that's just not how Visual Studio was designed. It is quite free from "boss override" switches, it gives its user unfettered access to configuration settings. Which ought to make sense to you, a developer can do far more damage with his code than with tinkering settings. If a dev intentionally changes an optimization setting then, surely, it is because he profiled the code and determined a better setting.
Anyhoo, Visual Studio isn't just useful to the dev, it is also useful to you. Write a little utility that parses the .vcproj file and checks if the optimization settings were overridden. It is a simple .xml file, you'll need about 5 lines of code. Run it in a pre-build event on your build grunt and fail the build if you deem it inappropriate. Dealing with the pissed-off developer cannot be automated however.
The only advice I can give is, if you open up the Property Manager for the project, and Right Click on one of the Configuration folders, it should popup a menu with an item called "Overidden Properties..." which in turn opens a dialog box that lists each property set in the project configuration that overrides a property sheet property sheet - along with the facility to select some or all, and delete the overrides.