Simple PHP script to check for valid links

A friend asked me for this and it turns out to be a bit trickier than you’d think.

There are plenty of tools for crawling a website and reporting broken links.  You can get 90% of this with just wget or curl.

But to check a list of links is a bit tricker.

The basic test is pretty simple


foreach ($urllist as $url) {
   if (fopen($url)) { print "valid"; }
}

But it requires allow_url_fopen to be enabled, doesn’t check for redirects, chokes if you’re behind a proxy, etc.

Using curl solves these particular problems, but requires libcurl to be built with your PHP, and it is quite clunky to use:

Anyway, here’s what I came up with: https://gist.github.com/1508261

You’ll still run into URL parsing problems (like a URL needs a trailing slash after then hostname (curl command line handles this fine, but not in PHP.)  Building the list of URLs is an exercise left to the reader.

If anyone wants it, I can put up a simple web UI wrapper with a text area, file upload button, or REST web service for scanning URLs.

Advertisements

What do you want from QA?

I’ve been reading about branding and customer development lately and decided  to exercise some of the concepts I’m learning.  One concept in costumer development is to think in terms of what the customer needs instead of what you provide.  To list benefits instead of features.

Since I do QA consulting, I thought I’d take a moment to think about what a QA manager might actually want, and then try to focus on what I can do to solve these pain points.

What do you want from QA?

  1. To get automation running
  2. To not have to maintain it
  3. To keep test execution in house (for security and simplicity)
  4. To not have to hire additional staff
  5. To make test case management painless less painful
  6. To not have to integrate yet another tool
  7. To not have to spend more time and money on training
  8. To get better coverage
  9. To know what is being covered and what isn’t
  10. To know what testing is finding the important bugs

This list is by no means exhaustive, and I’d love to hear what it is that you really want — either as a tester or manager.  Please leave comments or tweet @fijiaaron.

Landing a Tech Career by Accident was No Mistake

I wrote this as an example article for the About.com tech careers guide

A little over 10 years ago, at the height of the “dotcom” boom, I packed my bags and moved to Seattle from a small town in southern Oregon. I was a part-time student at a small technical college working construction between semesters. I’d just gotten a job at Microsoft.

I wasn’t the only one headed north to the technical hub that rivaled California’s “Silicon Valley” — seeking my fortune in the city that was built by prospectors bound for Alaska’s gold rush a century earlier. But much like many of those miners, I’d gone with the intention of getting rich quick and returning home, and ended up settling in the Pacific Northwest.

I didn’t strike gold with IPO stock options. But I did end up with a successful career in technology almost by accident.

The economic boom times of the late 1990’s are long gone, but technology is still one of the best performing sectors of the economy. And even though it’s tougher to land that crucial starting position, it’s not impossible. Here’s my story:

I’m a software tester with a great salary and I get calls from recruiters almost every day. My work is challenging and rewarding, and high in demand. Someone in my position could have excellent job security, or the freedom to take entrepreneurial risks and explore the world – which is what I have done. And I don’t even have a college degree.

While those were extraordinary times for the industry, I believe there is still plenty of opportunity for people to launch a career in technology, even if they don’t have the expected degrees or experience.

Technology is still a young industry, and performance matters more than credentials. It is a very democratic and merit oriented field.

It would be disingenuous to claim that it is easy to get your foot in the door, but once you have, if you work hard, you can still attain the stable career or entrepreneurial success that is no longer common in other fields. It is also true that career stability isn’t what it once was and that outsourcing and global competition make it more difficult to be secure in your position. But it’s also true that a hard working individual with technical expertise has no trouble finding work, and indeed, may have even more flexibility in their career than ever before.

Which sounds great in theory, but you might have a few questions, such as:

  • How can you get an entry level tech career when you’re under-qualified and there are so many other people looking for work at the same time?
  • How can you gain the necessary technical expertise to stand out and be in demand without getting that crucial first job?
  • How could you attain a tech career when you’re not a technologically oriented person?

While it’s true that almost every programming job lists a Bachelors Degree in Computer Science as a minimum requirement, in fact only about 50% of programmers meet this requirement. Many have degrees in other fields, or (like myself) have only taken some college courses.

Experience is more important than credentials. And thanks to inexpensive computers, free software, and internet resources, anyone can gain the necessary experience. Developing a website, contributing to an open source project, and networking with others in the industry are ways to gain and demonstrate your experience, and look great on your resume.

Programmers actually make up a small percentage of the technical workforce. Other roles such as project managers, analysts, designers, testers, operations & support personnel make up the majority of the workforce.

Creative ability & communication skills are highly sought after skills in the tech industry. And that does not necessarily mean artistic or literary talent. Being able to come up with creative ways to test software and explain what exactly is wrong with it are more important in my work than technical expertise.

Technology is a field that is full of potential career growth and opportunity. You don’t necessarily need a technical degree or expertise to land a tech career. With initiative and hard work, you can succeed in the industry even in tough economic times.


Qualifications

I have over 10 years experience in the tech industry & have held positions including customer support, system administration, software testing, and programming.

I’m a successful technology consultant with a popular blog about software testing and development.

I built a website for posting resumes, tracking job prospects, and networking.

I have extensive contacts in the tech industry and with tech recruiters, particularly in Seattle.

Data driven tests using Google Spreadsheets

I’m using Google Docs to share test data. That way test data (accounts, purchases etc.) can be set up in advance and test execution can be done using the pre-created data. It saves a lot of time and streamlines the testing effort.

When executing a test, a tester can just go to the google doc and get a test account already configured with the proper data for the scenario they are testing. This can also extend to automation with one extra step.

The test automation I’ve written in C# originally was written for a single scenario. After some refactoring, I had data driven test cases in NUnit. This is simple to accomplish with an annotation. The original test might look something like this:

using System;
using NUnit.Framework;

[TestFixture]
namespace oneshore.qa.testfixtures
{
    public class MyTest
    {
        [TestCase]
        public void testSanity()
        {
            Assert.IsTrue(Sky.color == Colors.BLUE);
        }
    }
}

By adding parameters to the [TestCase] attribute we can come up with a (slightly) data driven test:

        [TestCase(Color.BLUE, Result=true)]
        [TestCase(Color.GREEN, Result=false)]
        [TestCase(Color.RED, Result = false)]
        public bool testSanity(Color expectedColor)
        {
            return Sky.color == expectedColor;
        }

You can also specify a data source method with the TestCaseSource attribute:

       [TestCaseSource("MyDataMethod")]
        public void testInsanity(Color unexpectedColor)
        {
            if (unexpectedColor != Color.BLUE)
                Assert.IsFalse(Sky.color == unexpectedColor);
        }

        private IEnumerable<Color> MyDataMethod()
        {
            List<Color> colors = new List<Color>{Color.BLUE, Color.GREEN, Color.RED};
            
            foreach (Color color in colors)
                yield return color;
        }

It’s now a fairly simple exercise to get your test data from a file. And just one more step to use the Google Data API to get it from a spreadsheet. I’ll detail that next.