Group tests by class & namespace in Test Explorer - visual-studio-2012

In Visual Studio 2010, I could list my tests by full name. That way, my tests would be sorted by object, then method, then individual test case when I structured the tests as shown here:
http://haacked.com/archive/2012/01/02/structuring-unit-tests.aspx
However, in Visual Studio 2012 Ultimate RC Test Explorer, it lists the tests by test name (instead of "WidgetMaker.ctor.HappyPath", it just shows "HappyPath"). Is there a way to change the Test Explorer to show full names instead of the test name? Thanks.

Here is the answer in the end of the post :
http://blogs.msdn.com/b/visualstudioalm/archive/2012/03/08/what-s-new-in-visual-studio-11-beta-unit-testing.aspx
So, wait and see/hope...
EDIT : In the mean time, you still can have a similar interface by openning the *.vsmdi file in your solution items.

Related

How to Pass Values from MTM to Data Driven coded Ui Test case?

I am new to Coded UI.
I Have created data Driven coded UI test Case.I am Passing .CSV file as a data source. We have uploaded that Coded UI testcase into TFS. After Integrating Coded UI test Automated Build With MTM, It Runs fine from MTM for the values passed in .CSV file before automatic build created using VS2012.
Now my question is Is is possible to Pass Values to Automatic Coded UI in above scenario from MTM so that testers dont have to modify .CSV files from Visual studio? If Yes, Can anyone Please Guiid Me How?
Thanks in advance.
Yes it is possible. Here is an example line of what you will need to have at the top of your function. (Note that the TestMethod Attribute is contained within it) This line should replace the Datasource line that you have for your .CSV file.
[DataSource("Microsoft.VisualStudio.TestTools.DataSource.TestCase", "[InsertURLToCollectionHere];[InsertProjectNameHere]", "[InsertTestCaseNumber]", DataAccessMethod.Sequential), TestMethod]
Once you get that in your code you should be able to add the parameters to your TestSteps in MTM by adding the text of "#[InsertNameOfParameterHereWithoutSpaces]". At this point your Test cases should pull the data from MTM instead of your .CSV file.

Run VisualStudio classes (unit tests) from Excel?

Might be a silly question, but: Is it possible? For example, click a button in Excel that runs a specific C# unit test in VS, preferably also sending some info from Excel, and possible getting back the result of the run.
I've been doing this a lot in HP QTP/UFT, for running test cases. Now I'm using Selenium in C#/VS, and was thinking maybe there was a way to "streamline" it here too.
I'm using VS 2013 Express, btw - if there are possibilities for this, I realize they might be limited or non-existant in the Express version.
There is no standardized feature in any edition of Visual Studio that does this. One could build a plugin for Excel that does this. The Visual Studio Test Runner is a simple executable and it can output a XML file with the test results or you can attach your own logger (/logger) from the command line.
VSTO allows you to write a plugin for Excel that can execute C# code. Running the test runner and parsing the results from C# code should be relatively straight forward.
To populate the list of available tests, you can use /ListTests.

Which Visual Studio project types support Shift+Alt+D to open the Data Sources window?

In Visual Studio 2012, it appears that only maybe a third of the 20 or so C# project types support using Shift+Alt+D to open the "Data Sources" window (and none that I've found ever display the mythical "Data" menu bar option).
Is there any sort of guide as to which project types will allow you to work with data sources?
Also, is there any way to "adjust" the features of a project after it's been created?
Update: See my answer below for how to add the Data Sources function to an existing project.
I believe you are looking for this page:
http://msdn.microsoft.com/en-us/library/yft2c9ad.aspx
To quote msdn: "You can add a data source to a project only if it supports creating and working with data sources. For example, you can't open the Data Sources window in a project for a Windows Store app."
Basically, if using a database seems logical in your application, you can probably use one.
To answer your question about the "mythical 'Data' menu bar option", here's how you access it:
You just have to select "View", then "Other Windows", and finally "Data Sources"
And to answer your final question about, "Also, is there any way to 'adjust' the features of a project after it's been created?"
Yes, yes there is. If you mean as a compiled executable, one could simply decompile the project or use an ILcode editor. If you mean as a solution in visual studios, using the solution explorer you can access "My Project" and simply double click that to get a nice little gui for adjusting your project.
EDIT:
For an overload of information about data in visual studios, you can visit: http://msdn.microsoft.com/en-us/library/wzabh8c4.aspx
For more information about just the data source window, you can visit:
http://msdn.microsoft.com/en-us/library/6ckyxa83.aspx
Aha! There is a way to add data access to a project that lacks it, per: http://msdn.microsoft.com/en-us/library/bb907587.aspx. To quote:
To create a class from a database table
If you are working with a Web site project, and the project does not already have an App_Code folder, in Solution Explorer, right-click the project, click Add ASP.NET Folder, and then click App_Code.
In Solution Explorer, right-click the App_Code folder (for a Web site project) or the project (for a Web application project) and then click Add New Item.
Under Installed templates, select Linq to SQL Classes template, type a name for the .dbml file, and then click Add.
-- The Object Relational Designer window is displayed. [Note that this is the window that Shift-Alt-D displays]
In Server Explorer, drag the database tables or other objects (such as views) that you want to use with LINQ to SQL into the Object Relational Designer window.
-- The tables and their columns are represented as a entities in the designer window.
Save the .dbml file.
This creates .designer.cs or .designer.vb file that is located under the .dbml file. The file contains a class that represents the database and a class that represents the table. The parameterless constructor for the database class reads the connection string from the Web.config file.
(Note that, after performing this procedure you may get a message "The type or namespace name 'Linq' does not exist in the namespace 'System.Data'". The solution to this problem is found here.)

Update target button is disabled after schema comparison

I have created database project using VS 2012. Once the schema comparison is done, the update target button should be enabled to sync with target.
But it's not getting enabled. Any help plz.
I'm using VS 2012 with sp 3, SQL Server 2012,
Check the Error List if you have any error, I had a non recognized word in VS (but it did in SQL Server), I commented it out, re-compared and it was enabled successfully.
See if you have a "warning" message stating "Cannot generate deployment plan due to an internal error". If so, the Update and Generate Script buttons will be disabled.
Close Visual Studio, navigate to the folder containing the Database project and remove all (*.dbmdl) files. Then restart Visual Studio, re-run the compare schema at which point the Update button should be enabled.
Workaround:
In my case. Fixing Error was not priority task. Also i was not able to find any Error in Error List.
Its just you dont have to use your "Visual Studio Database Project" in source or target. Instead of using project, create a temp DataBase using script already with you.
Select this (or these) temp database(s) in source and (or) other in target.
Button must be Enabled.
For me getting difference was far more important than fixing the issue. Hope it helps you. With some more improvisation.
It seems your database project has sqlcmd variables without default values.
See:
http://www.andrewburrow.net/vs2012-schema-compare-buttons-disabled/
Hope this helps.
I couldn't see any errors in Error List, but I could see the errors in the Output tab
the everytime you open the "options" on "schema comparison" you must click on "compare" button again to activate the "update" button. However if it doesn't work at the first time, just close and reopen the Schema comparison file again.
For me, there were no errors visible in the Error List. This was because I had the "Show Issues Generated" drop down was set to "Build Only"; changing it to "Build + IntelliSense" allowed me to see the SQL errors that needed to be fixed to enable the Generate Script and Update buttons.
In SSDT I had the case where the update button was enabled but the generate script was not enabled. This was because my destination schema was my local solution (the *.sqlproj vs project).
It took a few minutes to dawn on me that the destination needed to be a real database to correctly generate the script.
And after all, when you have the available Update Target button and the disabled Generate Script button.
See if your source is a database and your target is your SSDT project.
If so then click "Switch source and target" button.
The Generate Script button will become available.
I.e. a SSDT project must be the source and a database must be the target in the Schema Compare window.
Workaround 2:
In my case, the Update button was greyed out because of there were errors warnings about a view that I created and added to the project earlier.
The problem was that the view was scripted to use full database qualified object naming. E.g. [databasename].[schemaname].[objectname], which works fine in SSMS, but causes a problem when it is checked in a DB Project.
If you use three part naming for referring an object in same DB project results in a error/warning in Visual Studio.
By changing the code to [schemaname].[objectname] in the definicion of the view removed the error warnings and enable the Update option. Happy days!
Credits:
https://visualstudio.uservoice.com/forums/121579-visual-studio-ide/suggestions/3577074-allow-three-part-naming-for-referring-a-db-object
https://visualstudio.uservoice.com/forums/121579-visual-studio-ide/suggestions/17396128-keep-update-and-generate-update-script-buttons
Typically the update button is grayed out when the database objects are available in the separate sql files physically inside the database project but are not included in the database project itself. I simply added those sql scripts into the project and the update button got enabled after comparing the schema.
In my case, the Update button was disabled because there was a scalar function that was modified and that function was used in a computed column definition.
My solution was to:
Manually drop the computed column(s) in the database
ALTER TABLE <your table> DROP COLUMN <your computed column>
Re-run the schema compare
The Update button was enabled, and the update completed successfully

TFS2010: Opening certain Excel reports gives error TF80076

When I try and open certain TFS2010 Excel reports I get the following error popup from Excel:
TF80076: The data in the work item is
not valid or you do not have
permissions to modify the data. Please
correct the problem and retry.
This is then followed by the popup:
TF208103: The initialization of the
workbook to connect to Team Foundation
Server was not successful. THe
workbook will close.... etc. etc..
... and Excel closes.
The reports that throw this error include:
Documents -> Samples and Templates ->
Project Management -> Document
Template - Iteration Backlog.xlsm (in
fact all reports in this directory
fail)
Documents -> Shared Documents ->
Iteration 1 -> Issues.xlsx (and all
reports in this directory also fail)
I believe that the error may be misleading as this only happens under one project collection and this is a project collection I had some trouble setting up so it was recreated a couple of times. I suspect that the SharePoint site that hosts the reports has got out of sync with the project collection.
Any ideas how to fix these errors?
Is there a way to regenerate the reports that error on the SharePoint site so that they can rebind with the project?
Thanks!
At the time the Team Project is generated those Excel sheets are also generated, pointing to "Iteration 1" Iteration (found at right-clicking Team Project, then "Team Project Settings">"Areas and Iterations...") & also referring to Work Item - Team Query "Iteration 1\Iteration Backlog".
If you managed to edit/delete those two, the Excel functionality shall be broken. Try to restore those back & the Excel shall work again. Then go to Excel Ribbon "Team" and choose "Configure\List" & set a valid query, pointing to a valid Iteration within your Team Project.
You can now delete the query, as well as the Team Project Iteration.
I had found this resolution here - (it's in German) & it was a lifesaver
There is also another route to possible success, taken partially from here:
Open Visual Studio, choose Team -> Team Project Collection Settings -> Process Template Manager. You can download the MSF 5 template to a folder on your hard drive. Then navigate to
FOLDER YOU DOWNLOADED TO\MSF for Agile Software Development v5.0\Windows SharePoint Services\Shared Documents\Project Management\
Under this folder you will see the (now connectionless) Iteration Backlog.xlsm.
Open it & under "Team" choose "New List" & connect it to your Query "Iteration 1" or similar suitable Query.
I also come across same issue. After trying following changes it started working.
Check from edit query in Azur if your query using variable like "#RecentProjectActivity" then replace it with other possible static references like you can refer some Area Path or any ID. Hope it will resolve your issue. Thank you.
I got this because the query Iteration 1/Iteration Backlog didn't work because I had change the iteration structure but not updated the query correspondingly.
So if you get this error, check that the query that the Excel list is using is working.
Faced similar problem when using # macros like '#currentiteration'.
Excel 2013 is not supporting importing Query with filters with macros to be added as List
Changing #currentiteration to absolute name of iteration resolved the issue

Resources