Tuesday, November 19, 2013

Quick Switching Between Demo Configurations

I’ve got a couple demos where I have to do some quick code changes, rebuild a project, then get a browser opened up to show changes on the UI. The point of this is to help folks understand how to avoid tests breaking when the sort order changes, or columns move around on the UI.

Before:

image

After:

image

Making my audience sit through the code changes is a waste of time—the code changes simply update sort and column order. My talk is on how to write good tests to deal with these situations, not show the code causing the changes.

Instead, I wired together a couple things to give me a hotkey that fires off the changes, builds the system, and launches a browser to the right page. First off is a Ruby script to copy files, build the project, and use Watir to launch the page:

require 'watir'
require 'optparse'
require 'fileutils'
 
 
def copy_start_files
    FileUtils.rm %w(Default.aspx Contacts.cs), :force => true
    FileUtils.cp("Contacts-Start.cs", "Contacts.cs")
    FileUtils.cp("Default-Start.aspx", "Default.aspx")
end
 
def copy_end_files
    FileUtils.rm %w(Default.aspx Contacts.cs), :force => true
    FileUtils.cp( "Contacts-End.cs", "Contacts.cs")
    FileUtils.cp( "Default-End.aspx", "Default.aspx")
end
 
def build_it
    system("C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\msbuild.exe RadControlsExamples.csproj")
end
 
def parse_opts
    $options = {}
    opts = OptionParser.new
    opts.banner = "Usage: ChangeSite [options]"
 
    opts.on("-s", "--start", "Set site to START") do
        $options[:start] = true
    end
 
    opts.on("-e", "--end", "Set site to END") do
        $options[:end] = true
    end
 
    opts.on("-h", "--help", "Display this screen") do
        puts opts
        exit
    end
 
    opts.parse(ARGV)    
    
    if ($options[:start].nil? && $options[:end].nil?)
        puts "Missing options"
        puts opts
        exit
    end
end
 
def launch_site
    $browser = Watir::Browser.start "http://localhost/WorkingWithLocators"
end
 
def do_the_work
    if $options[:start]
        copy_start_files()
    end
 
    if $options[:end]
        copy_end_files()
    end
 
    build_it()
    launch_site()
end
 
parse_opts()
do_the_work()

No, this isn’t the most awesomesaucest Ruby ever, but it works. I’ll clean it up when I need to.

The next step is to wire this up in your favorite hotkey/launcher. I use SlickRun because it’s awesome.

image

Now I can use SlickRun to launch my Ruby script. I can continue engaging the audience while the system updates, builds, and a browser shows up with the new content.

There are many ways to solve this particular problem. The steps above are how I chose to do it this time. Hopefully it’s useful to you!

Wednesday, July 24, 2013

Video of .NET Rocks Testing Episode

Way back in November of 2011 I was manning a booth at DevConnections in Las Vegas. Carl Franklin and Richard Campbell got me on board for a .NET Rocks show to talk about my new position at Telerik, why Test Studio is awesome, and a lot of discussion around keeping your test suites maintainable.

We ended up having to re-record the .NET show; however, the great folks at Grape City (now part of ComponentOne) got a video of the show. I hadn’t realized they posted it, or more likely Russ told me and I totally forgot about it… Regardless of the why, I just stumbled across the recording last night and thought I’d point readers to it.

The audio’s got some crowd background noise, but the video turned out pretty well despite all the noise from the very crowded vendor hall.

We covered a very wide range of topics during this chat. I hope I managed to convey the importance of keeping everything around testing focused on informing stakeholders informed about risk in the system.

One note: at about the 9:00-ish point, Richard or Carl asked me about breaking tests out into parallel chunks. I went off on using one browser session over several tests, but that sort of missed the point. Yes, you can and should parallelize when possible!

I hope you enjoy the talk, even if it is a couple years old.

Monday, June 24, 2013

STC 2012 Keynote Video

Last December I was fortunate enough to be invited as one of several keynoters at Software Testing Conference 2012 in Bangalore, India.

I spoke on Test Automation for the Non-Technical Tester—the idea that folks with a background in manual or less-technical testing are often mystified and/or outright fearful of test automation. My talk’s about ensuring those skilled testers understand that getting the right amount of automation in place frees them to do real testing instead of rote repetition of horrible manual test cases.

The volume on this video is very, very low, but it’s pretty clean so you should be able to hear well if you pump up things locally.

You can find the accompanying deck, as usual, over at the awesome SpeakerDeck.

Hope you enjoy this!

My “It’s Not About You” Talk from KalX 2013 is live!

Mike Eaton invited me back to his KalamazooX Conference this last year. He was kind enough to put me in the opening spot—pretty tough considering the amazing set of folks that followed me.

My talk, It’s Not About You, got recorded and is posted up on Vimeo. (You can find the deck at my SpeakerDeck page.)

Jim Holmes - It's not about you from The Kalamazoo X Conference on Vimeo.

This talk’s about stuff that’s really important to me. I’m never happy with any of my talks, but that’s likely my own Impostor Syndrome taking over.

(PS: If you want to watch it in HD, you’ll have to watch it directly off the Vimeo page.)

I hope you like the talk, and I hope you get something out of it.

Saturday, June 15, 2013

New Book Published!

Some of you may be aware I co-authored a book Windows Developer Power Tools some years ago. That book was a huge labor of love, and due to its nature, outdated the instant it was published. It took a lot out of me, and I swore I’d never write another book.

Like I’m good at promises…

It’s taken me some years, but I finally got around to authoring and publishing a new book. I’ve kept quiet about this because it’s something that’s pretty core to my fundamental beliefs and I wanted to get it done and published with some quiet space. I bit off a project about something that I’m passionate about, and that starts off quite a bit of argument and debate in the industry.

Without further ado, I’d like to announce publication of Best Practices in Software Engineering and Testing, published live on LeanPub.

Thanks for reading, thanks for caring about improving our industry through proper use of Best Practices.

Friday, May 24, 2013

Slides for my KalamazooX Conference Talk

Mike Eaton was kind enough to invite me back to give a talk at the KalamazooX Conference. KalX is my second favorite conference of any I’ve gone to. I’ll even put on my pompous hat and point out that I’ve now been to a lot of conferences across the US and a number of international ones. KalX blows all those away.

KalX is very special to me. I do CodeMash for the community, not for me. I do conferences like StirTrek for friends and the community, not for me. I do conferences like StarEast for my job, not for me.

KalX? It’s all about me. Sure, I do one 20 minute talk, but the rest of the time I’m getting re-energized, motivated, and inspired. I’ve been in bad need of that this last year, and once again Mike and his crew pulled off an amazing day.

My contribution was a variation of my “It’s Not About You” deck that I’ve done a couple times as a five minute lightning talk. I added on a section trying to address some things that I think are killing conferences—and that tie directly back to how we as individuals try to communicate. (Note: there’s profanity in some of the slides as examples, if that sort of thing bothers you.)

Great communication happens only when the person trying to deliver a message cares more about how they’re delivering that message than what the message actually is. Too often people let their personas take over and build walls between themselves and their intended audience. (“Audience” being the person across the table from you or 5,000 people in a conference keynote hall.)

I used examples including a conference keynoter, the PyCon train wreck, and Jesus Christ washing his disciples’ feet. I hadn’t thought about the range of those examples until Michael Letterle Tweeted about it:

image

That’s a pretty awesome compliment, and as you can see I’ve starred it to keep it in my Favorites list on Twitter for those times when I need a smile.

Slides from my Zero to Eight Talk

Yesterday I was invited to speak at The Path To Agility conference over in Columbus. This is another awesome conference here in the Heartland region which really showcases how many smart, motivated folks are here.

My talk was Zero to Eight: Starting a QA Team From Scratch. It covers my experience in a previous job where I worked to help build up a team of testers for a company that had zero formal quality processes or people in place. The talk’s really an experience report, but there are a few good specific takeaways from it.

I was in a small theater with only 50 seats which left a few attendees sitting on the stairs and some standing in the back. I sure appreciate the folks who stood the entire time, and I hope you felt it was worth it!

Wednesday, May 15, 2013

Sample Code & Slides from StarEast 2013 Talk

I gave a talk on Four Tips for Web Automation at StarEast 2013 this April. I’ve posted up my slides on SpeakerDeck

You can also find the demo code at my GitHub repository.

I’ll be doing a similar talk at StirTrek this Friday!

Wednesday, April 17, 2013

Slides From Quest 2013 Posted

Thanks to the folks who attended my talk at Quest 2013! I appreciated the interaction, and I hope you found the talk useful.

You can find my slides, and the mind map, here on SpeakerDeck.

Monday, April 01, 2013

Exciting News: I’m Now an MVP for ALM!

I just got news today that Microsoft has changed my Most Valuable Professional award from C# to Application Lifecycle Management (ALM). This is great news for me because this is much more in my wheelhouse both technically and passion-wise. Moving to ALM means I’ll be much more inline with things I work on regularly and care intensely about: testing, process, and making teams awesome.

I’m also very excited because I get to hang out with a bunch of awesome ALM geniuses like Esteban Garcia, Ryan Cromwell, and others. This is going to be awesome!

Oh, you thought my last post meant I wasn’t an MVP at all anymore? Oh, terribly sorry for that, but I figure there had to be something evil I could do on April Fool’s Day…

I’m No Longer a Microsoft MVP for C#

Yes, I realize it’s April Fools Day; however, this isn’t a joke. After a wonderful string of years, I got notification from Microsoft that I’m no longer an MVP for Visual C#. Frankly, I’d figured this was coming some time ago and I’m surprised it took this long.

Why? Because I don’t code for a living, and I don’t focus on C#. I don’t know anything about C# 4.0, contravariance, or covariance. Ask me to write a lambda, or explain how it differs from a delegate, and you’ll likely see my head explode or me head for the nearest bottle of scotch. I was put into the C# category in 2005 because they didn’t have a better spot to put me for all the community work that I was being recognized for, and it’s always been awkward for me.

My award wasn’t so much due to specific things I’ve done as it was due to all the awesome folks in the community, and I want to make sure to thank all the wonderful people who made the last seven or eight years great. Well, I can’t thank all y’all by name, but I hope you get the idea…

My time as a C# MVP has been awesome. I’ve gotten some wonderful opportunities, and I’ve met some amazing folks.

And by the way, no, I’m not going to go on an anti-MVP rant about how the program leeches off everyone and makes MVPs lose their morals and self-worth. The MVP program is what individuals make of it. I got a tremendous amount out of it, and again, thanks to everyone for their support over the years.

Nor am I going to give up .NET and go to Ruby. Duh. Smile

Despite this news I’m sure cool things will come along, so please don’t get your undies in a wad over my case. I’m good with it. It’s been a great experience.

Thursday, February 21, 2013

I’m No Longer the Evangelist for Test Studio

It’s true. I’ve been asked to give up my dream job that I’ve loved working for the last 20 or so months.

Instead, I’m now the Director of Engineering for Test Studio and am going to help with delivery of the automation tool I love so much.

Yes, I know. That was a bad trick to play. You’ve been reading my blog and haven’t figured this part of my “humor” yet?

In the new role I’ll be working closely with the teams in Austin and Sofia on planning and execution for future releases. It’s a scary but wonderfully exciting opportunity, and truth be told I had been missing being part of actively building software.

I’m not vanishing from the testing community—that involvement is a critical part of better understanding problems that we can help solve with Test Studio—but the amount and shape of my involvement will change as I move my focus to the teams at Test Studio.

One thing this brings up in a big way: Telerik needs another Evangelist to fill my position. We’re already looking for one, so this means we’ve got a second slot to fill, too!

Want to know more? Have a look at the job description and drop me a line to chat me up!

Wednesday, February 06, 2013

Cleaning Up Windows 2008 OS Drive

I try to keep the virtual machines I use for development, demos, and testing fairly lean. I use a smallish C: partition (60GB or so) and force everything to install to a second D: drive. All my projects and data end up on D:. This has saved me several times in the past when I’ve needed to rebuild a crashed VM—just reinstall the OS and off you go. I also like to think that it helps performance, even on a VM, by keeping IO off the operating system drive. No, I’ve never bothered to actually measure performance for this. Why do you ask?

Today I ran into a rather interesting set of problems when trying to run code coverage metrics in Visual Studio 2012. Of course my tester homies all this this is epically funny and cool.

image

A quick bit of troubleshooting found the following, uh, minor problem:

image

WinDirStat is the next tool to jump on, and it quickly shows where the problem lies. The winsxs folder, where backup copies of every DLL dating back to Windows 3.01 are stored. OK, so it’s not quite that bad, but every time anything’s impacted by Windows Update or a Service Pack then cruft gets thrown in there.

image

Disk Cleanup is a handy utility to clean out unneeded backups of these, plus lots of other goo; however, it’s not installed by default on a Windows 2008 server OS. You’ll need to go add the Desktop Experience Feature (Server Manager | Features | Add Feature | Desktop Experience), then Disk Cleanup will be available under Start | Accessories | System Tools.

I ran Disk Cleanup and got back a huge chunk of disk real estate – Disk Cleanup also let me know I had an extraordinary amount of temp file usage, too. And here I thought I’d been doing better regular maintenance on my server…

Next maybe I should go check the last time I changed the oil in the car.

 

(PS: Turns out this didn’t fix the epic crashes, but it was still needed. Hopefully it’s useful to you.)

Wednesday, January 30, 2013

Learning JustMock for Working with Nasty Dependencies

Update: I totally forgot to give mad props to colleague and good pal Phil Japikse for walking me through a couple things over IM in the course if noodling all this out.

I’ve given my Unit Testing 101 talk ten or 20 times over the last four or five years and I love it. I enjoy getting folks introduced to unit testing without having to deal with dogma issues around Test Driven Development, Test Occasionally Development, etc.

Part of the talk hits up working with mocking in order to get past a dependency on external providers. The example I use is a security provider used to check whether or not the current user’s authorized to update info for an employee.

In the past I’ve used Rhino.Mocks to work through this. I’ve used Rhino in a few projects over the years and it’s been a great tool for me.

Being the rather dense guy I am, I forgot that the awesome company I work for has its own mocking tool: JustMock. I figured it made sense to alter my tests to work with JustMock, if for no other reason than I could speak halfway intelligently to questions on it from other folks I interact with in the community.

One of the things I was most interested in was dealing with badly handled dependencies in code. The example I used previously had a nice constructor-injected interface-based security provider, so it was easy and clean to handle with Rhino. Here’s how it looks:

public class EmployeeUpdater
{
    private readonly IUpdateEmployeePermissible _updateEmployeeSecurityProvider;
 
    public EmployeeUpdater(
        IUpdateEmployeePermissible updateEmployeeSecurityProvider)
    {
        _updateEmployeeSecurityProvider = updateEmployeeSecurityProvider;
    }
 
    public Employee UpdateEmployeeRate(Employee targetEmployee, float newRate)
    {
        Employee updatedEmployee;
        if (_updateEmployeeSecurityProvider.
            CanUpdateEmployeeRate(targetEmployee.EmployeeId))
        //if (true)
        {
            updatedEmployee = new Employee(
                targetEmployee.EmployeeId, 
                targetEmployee.FirstName,
                targetEmployee.LastName,
                targetEmployee.Address, newRate);
        }
        else
        {
            throw new SecurityException(
                "Invoking user doesn't have permissions to update target target employee. " +
                                        targetEmployee);
        }
        return updatedEmployee;
    }
}

A test using Rhino, complete with interaction verification, is straightforward:

[Test]
public void Verify_security_provider_is_called()
{
    int userId = 1;
    int oldRate = 5;
    int newRate = 10;
 
    var mockProvider = MockRepository.GenerateMock<IUpdateEmployeePermissible>();
    mockProvider.Expect(x => x.CanUpdateEmployeeRate(userId)).Return(true);
 
    Employee current = new Employee(userId, "Jim", "Holmes", "Doghouse", oldRate);
    EmployeeUpdater updater = new EmployeeUpdater(mockProvider);
 
    Employee updated = updater.UpdateEmployeeRate(current, newRate);
 
    mockProvider.VerifyAllExpectations();
}

I took and muddied up the EmployeeUpdater a bit to mimic code we’ve either written ourselves or have seen: “new”ing up objects instead of injecting them, and using calls to static methods or classes. These situations make it tough to mock things out and will force you to move to a commercial mocking tool like TypeMock or JustMock. [1] (JustMock has an extremely powerful free version, but mocking concrete classes, “future mocks” of items “new”ed up instead of injected, or static requires the commercial version.)

Here’s my uglified EmployeeUpdater class. I simply created two different methods, one which newed up the security provider in it, another which hit the provider via a static call.

public class EmployeeUpdaterLegacyStyle
{
    public Employee UpdateEmployeeRate_ProviderNewedUpHere(Employee targetEmployee, float newRate)
    {
        UpdateEmployeeSecurityProvider _updateEmployeeSecurityProvider =
            new UpdateEmployeeSecurityProvider();
 
        Employee updatedEmployee;
        if (_updateEmployeeSecurityProvider.
        CanUpdateEmployeeRate(targetEmployee.EmployeeId))
        //if (true)
        {
            updatedEmployee = new Employee(targetEmployee.EmployeeId,
                targetEmployee.FirstName,
                targetEmployee.LastName,
                targetEmployee.Address, newRate);
        }
        else
        {
            throw new SecurityException(
                                        "Invoking user doesn't have permissions to update target target employee. " +
                                        targetEmployee);
        }
        return updatedEmployee;
    }
 
    public Employee UpdateEmployeeRate_ProviderIsStaticHere(Employee targetEmployee, float newRate)
    {
        Employee updatedEmployee;
        if (UpdateEmployeeSecurityProvider_Static.CanUpdateEmployeeRate(targetEmployee.EmployeeId))
        //if (true)
        {
            updatedEmployee = new Employee(targetEmployee.EmployeeId,
                targetEmployee.FirstName,
                targetEmployee.LastName,
                targetEmployee.Address, newRate);
        }
        else
        {
            throw new SecurityException(
                                 "Invoking user doesn't have permissions to update target target employee. " +
                                        targetEmployee);
        }
        return updatedEmployee;
    }
}

JustMock handles both quite nicely. First, working with “future” mocking to handle the variant that instantiates the object in the method. Note I’m working with a concrete class. No interfaces, no virtual, just a straight concrete class that’s instantiated right in my method above. The final mockedProvider.Assert() validates the security provider’s method was indeed called by the updater. (Comment out the //if(true) portion in the updater to see that test fail!)

public void Mocking_provider_newed_in_method()
{
    int userId = 1;
    int oldRate = 5;
    int newRate = 10;
 
    var mockedProvider =
        Mock.Create<UpdateEmployeeSecurityProvider>();
    //Standard syntax for mocking
    //Mock.Arrange(() => 
    //    mockedProvider.CanUpdateEmployeeRate(userId))
    //        .IgnoreInstance()
    //        .Returns(true)
    //        .Occurs(1);
 
    //using the fluent interface from JustMock.Helpers 
    mockedProvider.Arrange(x => x.CanUpdateEmployeeRate(userId))
                  .IgnoreInstance()
                  .Returns(true)
                  .Occurs(1);
 
    Employee current =
        new Employee(userId, "Jim", "Holmes", "Doghouse", oldRate);
    EmployeeUpdaterLegacyStyle legacyUpdater =
        new EmployeeUpdaterLegacyStyle();
    
    Employee updated = 
        legacyUpdater.UpdateEmployeeRate_ProviderNewedUpHere(current, newRate);
 
    Assert.AreEqual(updated.HourlyRate, newRate);
    //Standard assert
    Mock.Assert(mockedProvider);
    //Fluent from Helpers
    mockedProvider.Assert();
}

Here’s a test handling the static call variant above:

[Test]
public void Mocking_provider_called_statically()
{
    int userId = 1;
    int oldRate = 5;
    int newRate = 10;
 
    Mock.SetupStatic(typeof(UpdateEmployeeSecurityProvider_Static),
        StaticConstructor.Mocked);
 
    bool called = false;
    Mock.Arrange(() => 
        UpdateEmployeeSecurityProvider_Static.CanUpdateEmployeeRate(userId))
        .Returns(true)
        .Occurs(1);
 
    Employee current =
        new Employee(userId, "Jim", "Holmes", "Doghouse", oldRate);
    EmployeeUpdaterLegacyStyle legacyUpdater =
        new EmployeeUpdaterLegacyStyle();
 
    Employee updated = 
        legacyUpdater.UpdateEmployeeRate_ProviderIsStaticHere(current, newRate);
 
    Assert.AreEqual(updated.HourlyRate, newRate);
    Mock.Assert(() => 
        UpdateEmployeeSecurityProvider_Static.CanUpdateEmployeeRate(userId),
        Occurs.Exactly(1));
}

I’m sure there are better ways to leverage JustMock, and I’m sure there are cleaner ways to write the test. This exercise was more about me learning what capabilities JustMock has so I could keep it somewhat clear in my own head.

I’d love to hear feedback from folks who’ve worked with both mocking tools! Have you worked with Rhino.Mocks and JustMock? Have any thoughts?

[1]Perhaps Rhino.Mocks now handles these situations. I fully admit I haven’t kept up with it…

Subscribe (RSS)

The Leadership Journey