Showing posts with label tools. Show all posts
Showing posts with label tools. Show all posts

Resharper VS IntelliJ -> Extract Class

I do a lot of work with IntelliJ these days and wanted to see if my favourite toolchain (Visual Studio + Resharper) provide a better experience for extracting classes. Here are my learnings.

I have a simple class with too many responsibilities. Easily to see via the "And" in the method name (Nitriq had this as a code rule since the beginning http://www.nitriq.com/).

Lets say I want to split up this class in a "Mapper" and a "XmlGenerator".

How would you do this?
How would you do this in an automated way?

Code52 Show and Tell: My pet project CopyCat - Lessons learned

CopyCat – A big fat cat walking and waltzing the internetz

Figure: CopyCat – A big fat cat walking and waltzing the internetz
 

I am a pretty normal geek. At least I think I am normal and a geek. I see geeks as people (yes really) that want to play with things, discover new things and build things. When geeks play with things they discover new things quite often.
(Similar story heard and “adapted” from Scott Hanselman) 
After I ‘ve discovered something I want to scream it out to someone:

“Look at this dude!! Isn’t that awesome???”

A normal reaction that you get from a non-geek:

“Wow… Is this showing the weather in form of colors that you could just get by watching out the window?”

This is the pattern for the reaction that you normally get
“Wow… Is this <something> that does <somethingUselessAtBeginning> that you could just get by doing <somethingElse>?”

VS2010 - Pro Power Tools - Highlight the selected tab in the document well

If you are using Visual Studio 2010 and you don't have downloaded the Pro Power Tools, then do it now!
One awesome feature of that extension is the Document Well Plus, that gives you nice coloring of tab pages.
1 problem though… see below
image 
Bad Figure: VS2010 - Document well - Which one is the current selected tab?

Performance interview with LoadStorm

The company LoadStorm from Colorado U.S. did an interview with me about web performance and web testing.

I completely forgot to mention that here… so here is the link Peter Gfader
http://loadstorm.com/2010/performance-testing-interview-peter-gfader 

LoadStorm provides load testing from the cloud. Never saw such a nice and easy way (and UI) to hit your web servers VERY hard.
Only downside so far: No Silverlight runner … yet…

 

Additionally a couple of links to check the inner workings of your system...

Windows7 - Running applications as Administrator

I have a couple of tools that I want to run as Administrator, otherwise they want show up in VS2010.
I run VS2010 as Administrator, because I use IIS as web server for debugging…

 image
Figure: Check “Run this program as an administrator” to have that tool shown in every application

 

But, when you tick this checkbox your application wont start anymore… Why is that?

Not sure why though…

But autoruns from Sysinternals shows me that the app is running from the following location in the registry
C:\Users\petergfader\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup

image

 

Other 32bit applications are running from the registry… and that seems to work
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Run

 

So… long story short…

Put your 32 bit apps to that registry location
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Run

Reboot!
Tools are running!

Figure: How many tools do you use?

 

Post your tool in the comments if it is not on Scott’s list or on my list

Smack down!! WatiN vs Selenium vs VS2010 Test Lab Manager

*Updated* 21 March 2011: Updated how "Coded UI tests" finds a control with info from Balagans Blog - How does “Coded UI test” finds a control? 

 

We need Web functionality tests!!! (and a lot of people are already doing them)
Reasons?

  1. Easier to find bugs
  2. No need for a lot of manual testing
  3. Maintainability of your code (THIS IS BIG!!)
    1. When we change something (Code, DB, scripts, HTML,...) we want to verify if our user stories working as expected
    2. We setup web tests for each user story that we have.
  4. We can use web tests in load tests or stress tests
  5. … lots more

Note from Wikipedia
Stress testing: Simulates increased load, more than expected
Load testing: End to end performance testing under anticipated load

 

I tried the following 3 players (recommendations from work mates, and others..)

  1. Selenium
  2. WatiN
  3. Visual Studio 2010 & the Test & Lab Manager

All of these 3 tools provide a recording tool, where you can record your browsing actions and generate code from that.
This is important!!!
No one wants to write these tests manually!

 

Do the test recording

apcheck_thumb1 Selenium Test recorder just works.

Record your session. Copy & paste to Visual Studio. Done

ap--delete Watin Test recorder v2 throw exception

Bug reported here: http://sourceforge.net/tracker/index.php?func=detail&aid=2934193&group_id=193118&atid=944137

ap--delete Watin Test recorder V1 generates unsupported code -> manual fixing needed :-(

 

Code output of recorder

selenium.Open("/Public/default.aspx"); selenium.Click("//div[@id='userlogin']/div/div[2]"); selenium.Click("//div[@id='userstatusLoggedOut']/div/a/span"); selenium.WaitForPageToLoad("30000");
selenium.Type("ctl10_MainContentArea_ctl00_ctl00_CreateUserForm_CreateUserStepContainer_FirstName", "o"); selenium.Type("ctl10_MainContentArea_ctl00_ctl00_CreateUserForm_CreateUserStepContainer_LastName", "g"); selenium.Type("ctl10_MainContentArea_ctl00_ctl00_CreateUserForm_CreateUserStepContainer_Email", "peter@gfader.com"); selenium.Type("ctl10_MainContentArea_ctl00_ctl00_CreateUserForm_CreateUserStepContainer_ConfirmEmail", "peter@gfader.com"); selenium.Type("ctl10_MainContentArea_ctl00_ctl00_CreateUserForm_CreateUserStepContainer_Password", "password!"); selenium.Type("ctl10_MainContentArea_ctl00_ctl00_CreateUserForm_CreateUserStepContainer_ConfirmPassword", "password!"); selenium.Click("ctl10_MainContentArea_ctl00_ctl00_CreateUserForm___CustomNav0_StepNextButtonButton"); selenium.WaitForPageToLoad("30000");
selenium.Click("link=Log Out"); selenium.WaitForPageToLoad("30000");

Figure: Simulating a user registration with Selenium

 

IE ie = new IE("about:blank"); ie.GoTo("http://REMOVED.ssw.com.au/Public"); ie.Div(Find.ByCustom("innertext", "Member Login")).Click(); ie.Link(Find.ByUrl("http://REMOVED.ssw.com.au/Public/Profile/Register.aspx")).Click();
ie.TextField(Find.ByName("ctl10$MainContentArea$ctl00$ctl00$CreateUserForm$CreateUserStepContainer$FirstName")).TypeText("Peter"); ie.TextField(Find.ByName("ctl10$MainContentArea$ctl00$ctl00$CreateUserForm$CreateUserStepContainer$LastName")).TypeText("Gfader"); ie.TextField(Find.ByName("ctl10$MainContentArea$ctl00$ctl00$CreateUserForm$CreateUserStepContainer$Email")).TypeText("petermenuqggfader.com"); ie.TextField(Find.ByName("ctl10$MainContentArea$ctl00$ctl00$CreateUserForm$CreateUserStepContainer$Password")).TypeText("petermenuqggfader.com"); ie.TextField(Find.ByName("ctl10$MainContentArea$ctl00$ctl00$CreateUserForm$CreateUserStepContainer$Password")).TypeText("passmenumenuqword!"); ie.TextField(Find.ByName("ctl10$MainContentArea$ctl00$ctl00$CreateUserForm$CreateUserStepContainer$ConfirmPassword")).TypeText("passmenuqword!"); ie.Button(Find.ByName("ctl10$MainContentArea$ctl00$ctl00$CreateUserForm$__CustomNav0$StepNextButtonButton")).Click();

Figure: Simulating a user registration with WatiN

 

apcheck_thumb1 Selenium is a tool to create tests for web apps

apcheck_thumb1 Selenium’s output is a whole test class

apcheck_thumb1 Selenium’s output code is using relative URL’s (that you define in your test base URL)

apcheck_thumb1 Selenium code: Easy to read

ap--delete WatiN: The code output from the test recorder v1 is quite complicated to read.

I prefer Seleniums: “selenium.Click” instead of the long string and then seeing the “Click()”

// WatiN
watin.TextField(Find.ByName("ctl10$MainContentArea$ctl00$ctl00$CreateUserForm$CreateUserStepContainer$ConfirmPassword")).TypeText("password, f17");
watin.Button(Find.ByName("ctl10$MainContentArea$ctl00$ctl00$CreateUserForm$__CustomNav0$StepNextButtonButton")).Click();

// Selenium
selenium.Type("ctl10_MainContentArea_ctl00_ctl00_CreateUserForm_CreateUserStepContainer_ConfirmPassword", "password");
selenium.Click("ctl10_MainContentArea_ctl00_ctl00_CreateUserForm___CustomNav0_StepNextButtonButton");
         

Figure: Code comparison of WatiN with Selenium. Enter text in a password field and click on button

ap--delete WatiN : Output code from Watin Test recorder v1 was wrong.

Some input control TypeText() was missing
Finding of elements didn't always work E.g.  <a href="xx"> <span> My funkty test </span> </a>  

 

Running the tests

ap--delete Selenium needs a JAVA server to execute the tests

apcheck_thumb1 WatiN doesn't need a proxy server!

ap--delete Selenium is quite slow to run

Output from the Selenium Java server (see the 2 seconds of start up gap)

19:11:54.341 INFO - Command request: getNewBrowserSession[*chrome, http://REMOVED.ssw.com.au/Public/, ] on session null
19:11:54.341 INFO - creating new remote session
19:11:54.341 INFO - Allocated session 69581bdd207a4684b61f6c368af906f0 for http://REMOVED.ssw.com.au/Public/, launching...
19:11:54.370 INFO - Preparing Firefox profile...
19:11:56.895 INFO - Launching Firefox...

 

Code maintainance

apcheck_thumb1 Selenium makes working with Firefox perfectly together: uses the same name as in HTML

E.g. ctl10_MainContentArea_ctl00_ctl00_SubTotal

That means you can copy & paste from FireBug directly to Visual Studio

string priceSubTotalOnCheckout = selenium.GetText("ctl10_MainContentArea_ctl00_ctl00_SubTotal");

ap--delete Watin replaces the underscores with a dollar sign (This is annoying when copy paste from FireBug)

ctl10_MainContentArea_ctl00_ctl00_SubTotal
    needs to be converted to
ctl10$MainContentArea$ctl00$ctl00$SubTotal

string resultText = browser.Element(Find.ByName("ctl10$MainContentArea$ctl00$ctl00$SubTotal")).Text;

 

Note
image
Figure: Selenium is coming from the Java world, as you can see this here. No properties :-) --> GetXXX

 

What about  Visual Studio 2010 and Test & Lab Manager

  1. In Test & Lab Manager you define a test case that links to a user story
    1. User story: As a customer I want to search and buy a bag so that I satisfy my needs for a bag
    2. Test case below
      image
  2. Now you run you test with an Action recording
    1. This is easy. Just follow the instructions from the test case
    2. Done
  3. Close down Test Lab Manager and open Visual Studio, add "Coded UI test" with an "Existing action recording"
  4. Code that you get

[DataSource("Microsoft.VisualStudio.TestTools.DataSource.TestCase", "http://win-peterG:8080/tfs/DefaultCollection;Peter-Gfader-WebTest", "140", DataAccessMethod.Sequential), TestMethod] public void CodedUITestMethod1() { this.UIMap.Openbrowser(); this.UIMap.Gotostartpage();
this.UIMap.ClickonRegisterNew(); this.UIMap.EnterdetailsfirstnamelastnameemailpasswordParams.Ctl10MainContentAreaEditText = TestContext.DataRow["firstname"].ToString(); this.UIMap.EnterdetailsfirstnamelastnameemailpasswordParams.Ctl10MainContentAreaEdit1Text = TestContext.DataRow["lastname"].ToString(); this.UIMap.EnterdetailsfirstnamelastnameemailpasswordParams.Ctl10MainContentAreaEdit2Text1 = TestContext.DataRow["email"].ToString(); this.UIMap.EnterdetailsfirstnamelastnameemailpasswordParams.Ctl10MainContentAreaEdit3Text1 = TestContext.DataRow["email"].ToString(); this.UIMap.EnterdetailsfirstnamelastnameemailpasswordParams.Ctl10MainContentAreaEdit4Text = TestContext.DataRow["password"].ToString(); this.UIMap.EnterdetailsfirstnamelastnameemailpasswordParams.Ctl10MainContentAreaEdit5Text = TestContext.DataRow["password"].ToString(); this.UIMap.Enterdetailsfirstnamelastnameemailpassword(); this.UIMap.ClickonRegister();
this.UIMap.Searchforbag(); this.UIMap.Add1stbagfoundtoshoppingcart();
this.UIMap.Gotoshoppingcart();
this.UIMap.DoCheckout();
this.UIMap.EnterAddressdetails(); this.UIMap.Placeorder(); }

Figure: Code generated by VS2010 for a registration of a new user, searching for a bag, adding this bad and going through the checkout

apcheck_thumb1 VS2010 code is very easy to read. And there are a lot of things happening behind the scenes

UIMap is a huge file generated for you that does all the magic behind the scenes, like finding controls, clicking buttons, …

UIMap: Strongly typed representation of controls

 

How is Visual Studio finding controls?

        public HtmlInputButton RegisterButton
        {
            get
            {
                if ((this.mRegisterButton == null))
                {
                    this.mRegisterButton = new HtmlInputButton(this);

                    #region Search Criteria

                    this.mRegisterButton.SearchProperties[HtmlProperties.Button.Id] = "ctl10_MainContentArea_ctl00_ctl00_CreateUserForm___CustomNav0_StepNextButtonButton";
                    this.mRegisterButton.SearchProperties[HtmlProperties.Button.Name] = "ctl10$MainContentArea$ctl00$ctl00$CreateUserForm$__CustomNav0$StepNextButtonButton";
                    this.mRegisterButton.FilterProperties[HtmlProperties.Button.DisplayText] = "Register";
                    this.mRegisterButton.FilterProperties[HtmlProperties.Button.Type] = "submit";
                    this.mRegisterButton.FilterProperties[HtmlProperties.Button.Title] = null;
                    this.mRegisterButton.FilterProperties[HtmlProperties.Button.Class] = null;
                    this.mRegisterButton.FilterProperties[HtmlProperties.Button.ControlDefinition] = "id=ctl10_MainContentArea_ctl00_ctl00_Cre";
                    this.mRegisterButton.FilterProperties[HtmlProperties.Button.TagInstance] = "40";
                    this.mRegisterButton.WindowTitles.Add("Peter Gfader | Sign Up - Windows Internet Explorer");

                    #endregion

                }
                return this.mRegisterButton;
            }
        }

Figure: VS 2010 Beta2 generated code for finding a button on a web page. I think this is way TOO STRICT

ap--delete VS2010: All the "SearchProperties"above have to match, otherwise the button won’t be found. If too many controls are found from the "SearchProperties", the "FilterProperties" are applied one by one. All details on Balagans Blog - How does “Coded UI test” finds a control?

ap--delete There is no option to customize the default generated SearchProperties

 

I would probably change that to

        public HtmlInputButton RegisterButton
        {
            get
            {
                if ((this.mRegisterButton == null))
                {
                    this.mRegisterButton = new HtmlInputButton(this);
                    #region Search Criteria

                    this.mRegisterButton.FilterProperties[HtmlProperties.Button.DisplayText] = "Register";
                    this.mRegisterButton.FilterProperties[HtmlProperties.Button.Type] = "submit";

                    #endregion
                }
                return this.mRegisterButton;
            }
        }

apcheck_thumb1 Better way to search for the Register button. Filter on DisplayText and type of the control.
Note: This would fail if there are 2 buttons with "Register" and of type "Submit" on the page. Which is excellent!

 

Can VS2010 simulate a FireFox?
See this image for details about the VS2010 platform support
image
Figure: VS2010 platform support from http://videos.visitmix.com/MIX09/T83M

 

 WebAII looks very promising. I will definitely have a closer look on that tool in the next weeks, months…

 

Conclusion: Please count the apcheck_thumb1 green ticks and  ap--delete red crosses

Other interesting opinions about Watin and Selenium on testdrivendeveloper

 

PERSONAL
I would not automate the UI too much because that makes your test very fragile for future changes. That you will have sooner or later!

ap--delete BAD EXAMPLE
Create a coded UI test for a whole user interaction with your web app 
e.g. Register, Login, Browse, Find, Add to Shopping cart, Update Billing Address, Update Shipping Address, Checkout, Pay, See Order successful

Makes your UI test very fragile!
But could be a “Done” criteria for your SCRUM team: "An acceptance UI test must be written for each user story"

 

apcheck_thumb1 GOOD EXAMPLE
1. Create a coded UI tests for single screens
e.g. Logon screen:
  Assert "Username", "Password" boxes and "Login" button are there

2. Create a functional test for testing the actual Login functionality.

Notepad++ is awesome, and OneNote not so much…

I use Notepad++ since a couple of years now, just yesterday I found another awesome feature and reason to love NotePad++ more!
Ctrl+K (without the Ctrl+C) works in Notepad++ (as expected like Visual Studio) on editing autohotkey files and batch files (.bat) and a lot of other file types!!

Note
: Ctrl+K, Ctrl+C is the shortcut for commenting code

image
Figure: Commenting lines in NotePad++ with Ctrl+K

 

I would love to use OneNote, but I have following problems with it

  1. Where are the OneNote files stored?
    If we reformat drive because of system update, this is important to me!
  2. Onenote files can be opened only with Onenote :-(
  3. The UI is confusing to me, there are 3 tabs on 3 borders of the UI

clip_image002
Figure: BAD – What is the difference between the 3 different tabs? Is there a difference?

ap--check
The big PLUS for Onenote is the OCR feature “Copy Text from Picture”!!!!!
That is the only thing I use from Onenote

 

The big features I like from NotePad ++

  1. Syntax Highlighting in many different languages and file types (C#, html, … list is HUGE)
  2. Regular Expression Search/Replace
  3. File Status Auto-detection
    If you modify or delete a file which opened in Notepad++, you will be notified to update your document (reload the file or remove the file)
  4. Easy to use
  5. Auto Show last opened files

All features can be found here http://notepad-plus.sourceforge.net

Tools that I use and that are not on Scott Hanselman’s list of tools

I did a new install of Win7 RC last Saturday morning (my quickest install ever with my new SSD HD!!) During the install I wrote down the tools that I installed. I realised some of them are not on Scott Hanselman’s tools list! But almost all are mentioned in the comments on his blog post

This is the list of tools that I always install
And these are NOT on Scott’s tool list

Total Commander
File manager - the german “swiss army knife”. The best tool ever! Replaces Windows File Explorer, Winzip, Winrar, Beyond compare, FTP tools, …and more!

Fullshot
Screenshot utility - Don’t really like SnagIt, because its harder to use

Stroke It - Don’t be just a keyboard jed
Mouse gesture to the max - I used Symbol Commander, Sensiva in the past, but Stroke It is free

Stardock Fences
Organizes my desktop, and double-click  hide icons is great for presentations

SharpReader
My blog reader of choice, I know its old and they didn’t release a version since a couple of months / years …. but it just works

Shortkeys
Text replacement - I got used to that one and have 20 short cuts in there, don’t want to migrate to autohotkey…. to painful

Browser Selector
Depending on the URL that I click on emails it opens different browser, great! and other features described in this blog post about Browser Selector

Free Download Manager
1. Save all downloads in 1 place (FireFox, IE, …) 2. Resume downloads and 3. free

WinPatrol
Like “autorun” from sysinternals but keeps my system healthy in the background. If there is a change in my system –> Warning

irfanview
My picture viewer of choice. fast and shows all file extensions in the world

SSMS Tools
Enhances SQL Management Studio with features like: Create INSERT INTO script for table …

Nmap
If you don’t know it you don’t need it

mRemote
Save all your RDP, SSH, VNC connections in 1 place and connect by double click

 

Scott uses different tools and that is good.

My comments

What I found strange that there is no mouse gestures tool. I think he is a keyboard master and is not using a mouse at all probably :-) Or he is using some authotkey script for mouse gestures…

There is no file manager in Scott’s list. Just FAR file manager (DOS, crazy!!)  :-(

"Windows Update" and "Google Updater" are not enough...

  • Windows Update is great for Windows
  • Google Updater works great for the Applications contained in Google Pack.

But what about all other software?

Use SSW Diagnostics - Utility to ensure your system is up to date.
Note
Ok, I'm starting to work at SSW :-)  
but I like that tool and used it already before...

image

Checks all of your software, if you have latest version!

Clickonce - no install needed, click and run!

 

All applications must be upgraded manually... but there is one click download link...

Goodbye Resharper - Ohne F12 kann ich nicht leben

Hab 2 Tage Reshaper von Jetbrains getestet, und muss sagen: - VS.2005 wird seehhr langsam, fast nicht mehr benützbar - F12 Funktionstaste ist anders belegt. In Resharper: --> Next Error Vorher in Vs: --> Go to Definition Und F12 hab ich DAUERND benützt. Ohne dem kann ich nicht leben!!!

.NET Tools: Reflector + Add-Ins

Reflector: class browser for .NET components .NET Reflector Add-Ins: Home Various usefull addIns for reflector: MutantDesign.ManagedAddIns ClassView CodeModelView DelphiLanguage FileDisassembler SourceView Reflector Addins

Usefull Tool in daily .net developing

With this simple tool its very easy to test some lines of code. Without starting the Visual Studio Monster. SnippetCompiler App

Latest Posts

Popular Posts