God, I love this stuff.
So I sit down, and in less than an hour build a simple model-based testing program for my Rock Paper Scissors web service.
Basically, I start by defining all the valid states for my service.
private enum states { Offline, ShakeHands, TakeTurn, ReceiveTurnFeedback, ReceiveGameFeedback };
Then I create an array indicating all the valid state from-to combinations.
private states [] testorders = {states.Offline, states.ShakeHands, states.ShakeHands, states.TakeTurn, states.ShakeHands, states.ReceiveGameFeedback, states.TakeTurn, states.ReceiveTurnFeedback, states.ReceiveTurnFeedback, states.TakeTurn, states.ReceiveTurnFeedback, states.ReceiveGameFeedback, states.ReceiveGameFeedback, states.Offline};
So, taking the first line of the array above, if the rps service is currently offline, the only valid action would be to shake hands. If you have just shaken hands, you have two choices: you can either take a turn, or receive game feedback (close the game down).
The actual code is rather simple. If my RPS service were a professional application, I would improve this a bit. Basically, I keep track of the current state, loop through the array looking for all the possible actions, and then randomly take one.
// What can my next states be? ptr = 0; for (int j = 0; j < testorders.Length - 1; j += 2) { if (testorders[j] == CurrentState) { // Add this to the list NextState[ptr++] = testorders[j+1]; } }
// Pick one CurrentState = NextState[rndm.Next(0, ptr - 1)];
If I do this enough times, I will have tested every allowable combination of actions and states. And somehow there was a new allowable action, for instance, SayNiceGame(), I could add that to my states array easily enough.
Possible improvements to my application would include testing for exceptions, and handling them gracefully; keeping statistics about the number of tests run; calculating the percentages of each choice made (rock, paper and scissors)... You can start with a basic test model, and make it more complex as you have time.
Testing Web Service, v1.0 - C# Source Code
Testing Web Service, v1.0 - .NET Binary
Josh Ledgard points (through Nihit Kaul) to an excellent article on testing methodologies - well worth a read. Automated testing seems to be the new "hot" technology of 2004.
For Testers: Nihit Kaul Talks Up Model Based Testing
It was my belief as a test lead and is still my belief. To test a product with any amount of interesting complexity you need to find good ways to reduce a reliance on manual processes. If you test manually you need automation. If you are writing a test plan you need to have a machine figure out the details. If you start writing automation you need to reduce the cost of writing automation. One way to reduce costs and start abstracting the testing problems is through model based testing. Nihit has a good introduction article to the practice you should read.
Internally we have gone so far as to write automation that abstracts Visual Studio, write a model that represents a feature, and have that model make calls to the automation. This reduces the cost of writing scripted automation. Only a few teams have started doing this and I think it has a long way to go, but I would be surprised if the use of such practices don't take off quickly.
I have written about Eric Sink on this blog a couple of times before, but it's time to do it again.
Eric runs a successful software company called SourceGear, who have a professional source control product called Vault. He writes a regular column for MSDN called the Business of Software, and on his personal blog is now posting his take on the 22 Immutable Laws of Marketing.
If you are at all interested in the business side of the software industry, read Eric Sink. As soon as possible.
Here's how to get rid of the welcome screen, and allow your computer to automatically logon upon boot. Thanks to TweakXP for the info.
Note: This is not a good idea in an open environment, such as the office, but makes sense for the Home PC, especially when there is only one user account and no password.
1. Click Start on the Windows taskbar, and then click Run.
2. In the Open box, type:
control userpasswords2
then click OK.
3. In the dialog box that appears, you'll see: "Users must enter a user name and password to use this computer" check box. Enabled will require users to logon, disabling will make XP automatically logon to the Administrator account.
4. Go to Control Panel / User Accounts, and click “Change the way users log on or off”, and untick both “Use the Welcome Screen” and “Use Fast User Switching”.
that is the question.
Today I had a pleasant experience modifying some open source software to meet a particular need. The software was FlexWiki and the changes I made mostly had to do with incorporating Google AdSense over at my Wiki pages.
The changes themselves were trivial. I wanted to start serving ad banners with my wiki pages. The wiki is not templated, so I could not just pop in and modify the HTML. I had to download the source code for Visual C# .NET, find the relevant method, and hard code the Google AdSense in there. Once I recompiled and uploaded the new DLL, everything worked like a charm first time. (I love it when things work like they are supposed to.)
Now what made this whole process easy was that the source code was freely available. If this were a closed source project, I would not have been able to incorporate my ad code so easily. So, in effect, my experience is the "poster child" for the open source movement. If you have an itch, you can scratch it yourself. This isn't about politics, anti-capitalism, freedom, or any other grandiose concept - it's about being able to make changes you need in a matter of minutes.
The downside to having the freedom to change the fundamentals of an application becomes obvious rather quickly. Here I sit with a version of FlexWiki that is no longer compatible with the master version. When the developers release the next version of this software, I will be stuck trying to integrate their changes with my own. Most likely I would lose my changes entirely, and have to reimplement them (if I can remember what they were).
So open source, while good for scratching an immediate itch, allows the user to paint themselves into a "can't upgrade" corner. No bug fixes. No security enhancements. And no new features. On top of that, if FlexWiki starts misbehaving and I can't locate the source of the problem, who do I call? Are the original developers now going to be responsible for helping me find and fix problems that may be of my own doing? Of course not.
So while open source makes sense for people like me, who have the knowledge and expertise to integrate my changes with any new versions that come down the road, it does not make sense for crucial end-user software like Windows or Office.
Today I watched 5 short training videos at Visual Basic At The Movies, and for my troubles Microsoft is sending me a free copy of Visual Basic .NET 2003. For those of you wanting to get started in VB but don't have a copy of the Visual Studio IDE, this is a great offer.
Now, I could have chosen to get a free “Developer Welcome Pack” instead, since I already have VB installed at home. But while poking around the Internet looking for more information on what exactly a welcome pack is, I discovered a second Microsoft promotion offering to send the Welcome Pack free for existing developers. So why settle for one or another when I can get both?
Exercise? Me? Yep.
I have never been an exerciser of any sort, and the only sport I regularly play is golf. But I think I have stumbled upon an exercise regimen that, if it lasts from now until fall, might become a life-long habit.
I've started to bike to work - everyday. And it hasn't killed me yet.
A couple of key events have aligned in order for me to make the switch from car to bike. The first key event was that I realized how crazy it is for me to drive to work in my situation. Three weeks ago, I started working 5 minutes away from home by car. It's extremely close by car, but not close enough to walk. And, after a year of getting free parking at my last job, I now have to pay for it every day (only $6 per day, but still...) Plus gas prices have nearly doubled, so I probably spend $5 a day on gas in my SUV. All that got me thinking... I wish there was another way to get to work besides driving.
Walking would take me an hour, so that is impractical. Public transit would take at least 45 minutes, since I have to walk a little bit, and then take two streetcars - there is no direct route.
The second key event was a poster that appeared in the elevator of my condo last week: "We're building a new indoor bike locker for residents. Opens next week."
Well, after spending a couple of weeks feeling guilty about driving, the poster sealed the deal. I needed to buy a bike. I did, and now I have biked to work twice this week. (The only two days I didn't was when it was raining on Tuesday, and when I had a dentist appointment on Thursday. And I might start to bike in the rain, since that's what real cyclists do!) It takes me only 15 minutes to bike to work each way - and on beautiful days like today, I really enjoy the journey.
Plus if you think about it in terms of money, which I don't, but if you do... the bike will pay for itself in three weeks. 15 days of no driving will pay for the $150 I paid for the bike.
Blue Jays
My wife and I saw the Toronto Blue Jays defeat the Texas Rangers tonight. Every year we try and go a couple of times to the Skydome to see them play. Lately, we always go to Club Windows restaurant, which overlooks the field at Skydome. I highly recommend the experience. All-you-can-eat buffet dinner and a live ball game for $49 Canadian. Top stadium seats at the Skydome are $37 to $54. So basically, for the same price you would pay to sit in the far corner of the stadium plus have a beer and a hot dog, you get to watch the game from the open-air restaurant the same distance away, with much better food, service and comfort.
I probably shouldn't be recommending this to people, lest Windows start to get too busy for us to go.
My New Job
I don't want to jinx it, but things are going great at my new job. I really am getting into a groove - the time just flies by. I blink, and it's lunch time. Blink again, and it's 4pm. Where has the time gone?
You know when you are in the coding phase of a project, and you get into a "write a little code, execute it, fix the bugs, execute it again, it works, write some more code, execute it.... " cycle? You're just chugging away, and by the end of the day you realize you got so much of the core work done? Nothing beats the satisfaction of spending a day writing a lot of kick-ass code, everything is working and the code itself is a beauty to behold... I love those days. I wish every day was like that. I kind of wish I could work tomorrow (Saturday) just to keep the groove going. Kind of, but I'll take the day off anyway. ;)
|