Selenium C# Auto generated Code for Visual Studio 2010 - visual-studio-2010

I would like to test a Website UI.
Is it possible to record all Website clicked elements using Visual Studio 2010 (just like Selenium IDE does)?
Is there a integration between Visual Studio 2010 and Selenium in order to use Selenium auto generated C# code inside VS2010?
thank you

The way I have done this is record the test in Selenium IDE and save as C# and NUnit. NUnit asserts are almost identical to MSTest unit tests. I then paste into a Visual Studio unit test and hand modify the small number of deficiencies.

The Selenium equivalent in VS is inside the Team System / Test edition component.
The allows you to capture a "webtest" by clicking a workflow inside IE and then (if you want) running a series of these webtests as a "loadtest".
All the webtests can be run on their own or you can link a few of them together to approximate a Selenium Test Suite.

You can add a new Format for export using Options->Formats->Source (button). Copy the existing C# (Remote Control) entry and alter the java to output MSTest tests. It's pretty easy.

Related

Has anyone integrated NUnit with Visual Studio 2010?

Has anyone integrated NUnit with Visual Studio? I'm trying to set up a build pipeline like this one. But, I'm pretty new to .NET and I'm still understanding how things work. There are many resources in the internet on NUnit + VS, and I'm confused.
I'd recommend you to use Resharper.
As some say, "It just works".
Disadvantages/side effects of this choice in your case could be:
1. Resharper is not free;
2. Running unit-tests is minor part of Resharper - it also includes tons of other features, which you maybe do not need for now(but you can disable most of them in setttings).
Free solution is - Visual Nunit 2010 Visual studio extension. Free and does exactly what you want.
UPDATE
How to add NUnit to your project.
I've found this tutorial. Follow it step-by-step, I've found it helpful and complete for .NET novices.
The only difference is that in Running Unit-Tests section for running tests author uses test runner tool that is distributed within NUnit itself, but you can use ReSharper runner as described in JetBrains' docs
I'm using this:
http://visualstudiogallery.msdn.microsoft.com/c8164c71-0836-4471-80ce-633383031099
Which works quite well for me. You can access it within VS2010 from View->Other Windows->Visual NUnit
I used TestDriven until it was no longer free, I used Resharper but felt it slowed down my machine too much, I tried the VisualNUnit extension but it appeared to spawn multiple processes of itself that would keep a hold on some of my DLLs, I added NUnit itself as a command under Visual Studio Tools (and also with a toolbar button and some macros in Visual Studio to start the current test and attach) but that cost some effort to set up and didn't feel smooth enough after being spoiled with tools like TestDriven. Eventually I tried NCrunch... I am hooked ever since, and I have even started to favor it over TestDriven! the next tool on my "NUnit bucket list" will be the NUnit extension for Visual Studio 11.
PS: NCrunch should work on your Visual Studio 2010 and the homepage has a very decent demo video.
First download and install the NUnit
Step 1: Open Visual studio
Step 2: Open your project
Step 3: Select Properties from Solution Explorer
Step 4: Select Debug option in the properties window
step 5: select 'Start external program' under the section 'Start Action'
Step 6: Select the path of the NUnit file
Step 7: Save it.
After that when you debug your project NUnit will open.
Setting up Visual C#2010 Express with NUnit
The original and still quite ok test runner.
Test Driven .net
Used to be free, but now costs a small fee unless you're a student or open source developer.
Visual Studio 2011(BETA) is compatible with 2010 and provides test runners out of the box. Refer to Visual Studio 11 Beta Unit Testing – What’s New and Visual Studio 11 Beta - Unit Testing Plugins List. For continuous integration (CI) server U can use TeamCity and also run those test on the server.

Export Visual Studio test results in some document / report format?

It is possible to export/print Visual Studio test results in some document format, maybe including test details?
Thanks
I don't know MSTest all too good, but you can run the Visual Studio tests via the Gallio framework (which is free, you can get it here), and that gives a very nice (and very detailed) test report.
HTH!

Does Visual Studio Test Essentials/Test Runner run web & load tests?

Looking at Amit Chatterjee's Blog post on the upcoming Visual Studio Test Essentials product and in the image he has (below) he basically he says that all the blue blocks will be in Test Essentials, while all the green will be in Visual Studio Test Edition.
(source: msdn.com)
I see Test Runner is on the blue block side - does that mean that I can create the web & load tests (green blocks) in Visual Studio Test Edition, and then using Test Runner in Test Essentials to actually run them?
The answer is yes - You will be able to create the test in Visual Studio Test Edition and use Test Runner to execute them.

How to debug mbunit/Gallio unit tests in visual studio

I am trying to figure out how I can hit breakpoints in my unit tests that are written with MbUnit/Gallio. I tried running Gallio.Icarus, attaching vs debugger to it, the breakpoints weren't hit.
Next I tried to start Gallio.Echo from project properties, but I was getting an error message, after supplying the dll, saying only .exe's can be tested.
The unit test runs fine from Gallio.Icarus, however, I am unable to debug them.
Thanks!
Grab Gallio v3.0.6 Update 1. Load up your tests and click on the shiny new "Debug" button in the Icarus GUI itself.
I would use TestDriven.Net for this. It supports MbUnit tests, and you can debug by simply right clicking from within Visual Studio
A much better answer is found here:
gallio test runner plugin to visual studio 2010
The answer is to add the following section to your *.csproj file the after the <ProjectGuid> section section:
<ProjectTypeGuids>
{3AC096D0-A1C2-E12C-1390-A8335801FDAB}
; {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
</ProjectTypeGuids>
See Also:
How Does Visual Studio Identiy test projects?
A list of supported VS2010 project types
Second list of GuIDs for supported project types

How can I get started using Nunit in my Visual Studio project?

I want to start using Nunit (finally), I am using Visual Studio 2008.
Is it as simple as importing Nunit into my test project?
I remember seeing a GUI for NUnit, does that do the exact same thing that a separate test project would do, except show you the pass/fail visually?
I like to add a link to NUnit in my external tools.
Under Tools->External Tools add NUnit
Title: &NUnit
Command: <path to nunit>
Arguments $(ProjectFileName) /run
Initial directory: $(ProjectDir)
After that you can quickly run it by compiling then hitting alt-t + n
Yes, that's basically it. Personally I find the unit test runner which comes with ReSharper to be excellent - and the tool itself is well worth the licence feel. Alternatively there's TestDriven.NET.
Having a test project which runs nunit-gui or nunit-console separately is all very well, but you really want the whole unit testing experience to be as seamless as possible. The easier it is to write and run tests, the more likely you are to do it - which is a very good thing. Don't underestimate the gradual build-up of frustration due to a slightly poorer user experience, flipping between windows etc.
NUnit is something that isn't inside Visual Studio 2008. It does have a console OR a graphical user interface (gui) that can be run both outside VS2008 OR can be attached to the process of VS2008 for debugging.
If you do want something inside VS2008 you need to have a third party pluging like ReSharper.
Edit: This has been answered in the past (not for VS2008 specificly but still relevant)
I've used TestDriven.NET with VS2005, and it has changed how I develop and test code.
You can run all of the tests on any class, module, project, or solution. You can also run a test in the debugger, which is tremendously useful to diagnose and fix issues when they crop up.
The GUI is nice, but if you run your tests often, you'll probably abandon it for a faster/integrated runner.
In any case, you have some options on how to run your tests:
NUnit.Gui.Exe -- you can run this & select your test project dll to run the tests. While it is open it will refresh when you build, so you can ALT-TAB to it & re-run your tets. Another technique I've seen is to set this application as the startup program for your test project. Then set your test project as the startup project and push F5.
Download & use TestDriven.net. This is fast and lets you run tests from a right click menu, while you're sitting on a test or at a node in the solution explorer. This is what I use mostly. I have it mapped to CTRL+T for quick access.
Resharper has a test runner as well. This gives you the GUI with red/green lights inside of visual studio. It also gives you a little icon next to each of your tests to quickly run them.
You can use the plugin NUnitForVS that is available here: http://www.codeplex.com/NUnitForVS
This integrates the test running and results in your VS 2008 IDE. We've been using it for a couple of months and it's working well for us.
You should also remember that with VS 2008 professional you can use the MS Unit testing tool that was previously only available in the team versions.
You can run it as external program, but as for me it is not very nice. I like, when test starts within the VS. So, if you have ReSharpe you can go to Tools -> Options -> Environment -> Keyboard and set the hot key for ReSharper_UnitTest_ContextRun. I set it to Ctrl + t.
I attach my nunit console program to the Post-build event so every time I build my project the tests are run without the need for third party tools (apart from NUnit). I'm using Visual Studio 2010, but I am pretty sure you can achieve the same behaviour in Visual Studio 2008.
To do this:
Open the project's properties window (the project containing the tests)
In the Post-build event command line add the line:
"C:\Program Files (x86)\NUnit 2.5.10\bin\net-2.0\nunit-console-x86.exe" "$(TargetDir)$(TargetFileName)"
Build the project and the output should be written to the Ouptput window (Build). It's important to choose the x86 version of the console runner.

Resources