I decided to write a blog post to see what time it is. So here we go! Scroll down if you just want the real content.
First, an explanation for this unusual behavior: our boss has us doing this productivity thing today. Outlook is set to work offline, we hid the time from the taskbar, I hid my phone and wallet and keys, and now I can’t find them. So now I’m dying to find out what time it is. When I finish posting this, I will get to see what time it was posted at, and therefore the time now (then). Sure, there are other ways of finding the time, but this way I can be productive while looking at the time! Or maybe that is just overkill and I feel like taking a break from writing sample code for now.
It was either my first or second day on the job when my boss told me to look into Coded UI Testing in Visual Studio. I figured it out piece by piece as I went along, but I wish there was just an easier way to learn it, so here’s to helping those of you who are having the same experience I had when I started looking at Coded UI Testing. I strongly believe that there is already plenty of material out there on this subject, so I will link to a bunch of other articles. However, the order in which you read the articles makes a difference. The first thing I read was about data-driven coded ui tests, and the first step listed was “right-click the coded ui test and click properties.” I then found a simpler step-by-step tutorial but it was still hard for me to follow due to my inexperience with Visual Studio 2010.
I couldn’t find a good explanation of Coded UI tests all in one place, so I’ll just write a paragraph about that. Coded UI testing is a feature included in Visual Studio 2010 Premium and Ultimate. (Probably won’t find it in the express edition you can get for free) Coded UI tests allow developers to easily create automated tests that test their user interface. They can be similar to unit tests if the tester chooses to use them as such, however they can also be used to record huge series of actions. And my favorite part: A developer can easily modify UI tests without re-recording, but rather by simply editing a little bit of code. If used properly, the Coded UI tests can be powerful tools to developers, and they can also be two weeks of hell to an intern that doesn’t know what he or she is doing. One of my favorite things is test re-usability, and I plan to write more about that in the future, so check back!
Okay, the real content: links.
How to: Generate a Coded UI Test by Recording the Application Under Test – This is a really good starting place, assuming you at the very least know your way around Windows, and Visual Studio 2010, or know how to figure them out. Oh, it might also assume knowledge of mouse and keyboard use as well. If you have any problems with the pre-reqs, you might be too old. For step 4, I would recommend opening the calculator that comes with Windows, and try recording both button clicks and typing calculations, so you can see the variety of code that will be generated.
How to: Create a Data-Driven Coded UI Test – Now that you can record tests, you might try testing multiple things with the same test. Try modifying this so that it tests multiplying and subtracting as well, instead of just addition. Start playing around to see what else you can test!
Understanding the code generated by “Coded UI Test” – Part 1 – Also read part 2. This article I think is fundamental to understanding some of the concepts behind Coded UI tests, and understanding what the generated code does, why the generated code is the way it is. With the knowledge from this article, you should be able to do a lot with Coded UI Tests!
Best Practices for Coded UI Tests – Read this! Pay attention to every tip, if you have time try looking over some of the articles. One that I didn’t even notice today, and I realize is extremely valuable to the testing I do is about creating separate UIMaps. The tips on this page Will get you running on a great path to some good tests.
Finally, you can check out lots more links at Mathew Aniyan’s Blog, who happens to be an excellent genius in the field of Coded UI tests. If you ever get stuck, don’t forget to Google it first!