How to Get Started Automating Your API Tests | TechWell

How to Get Started Automating Your API Tests

Integrating API tests into the software development lifecycle

There are a variety of reasons testing teams decide it’s time to introduce test automation. Maybe someone on your team has been building their technical chops, or perhaps a new manager or CTO has gotten more involved and wants to see QA advance. Or maybe your organization is one of the 74 percent of companies transitioning to DevOps and you want to support the transition by shortening your test cycles with automation, which can make continuous integration and delivery possible by increasing testing efficiency.

Today, you’d be hard-pressed to find a QA team that isn’t doing test automation, or at least gearing up for it. Yet automation is still under-exploited in QA, according to Capgemini’s 2017–18 World Quality Report.

So what’s the best way to get started or expand your existing strategy? An area that is often overlooked is automating API testing.

API test scripts are faster and easier to write than other types of scripts and can be fairly simple tests. And while you need someone who’s tech-savvy to write them, you don’t necessarily need an experienced developer.

An added benefit is that API testing can be included in your continuous integration tools for execution and quick feedback on failures to the developers, giving you a quick win for providing more continuous feedback to your development team.

API testing has marked benefits for security-focused organizations. If you’re not testing APIs for vulnerabilities and you jump straight into testing the UI instead, you could be missing a whole suite of basic security tests focused on authentication and authorization. And if there is a security breach in the services layer, it could expose the entire database, rather than just an individual user’s data.

If you don’t have a tester with development experience who can write custom test frameworks, there are wonderful tools like Postman and Newman that can help you write API tests, but you’ll still be able execute the tests from a command line so you can include the tests in your build pipeline. Other good options include SmartBear’s SoapUI and Apache JMeter. If you’re practicing continuous integration, you can set up your tools to kick off API tests as soon as new code is committed to the repository.

Here’s a rundown of how API tests could be integrated into the software development lifecycle:

Depiction of five steps below of how API tests could be integrated into the software development lifecycle

  1. QA writes a regression suite to test all APIs.
  2. Dev commits new code to the repository.
  3. Configure Jenkins to automatically execute a job when code is committed.
    • Code builds in Jenkins
    • Code is deployed to a test environment
    • API tests are executed against the environment to which code was just deployedDevelopers and testers are notified via email if the test fails
  4. If this is a new API endpoint that the developer worked on, new tests get written and committed, then Jenkins builds and runs the tests again. (Note: Because APIs can have really detailed specifications, the tests can be written at the same time as the code.)
  5. If the code is still broken, the tester can create a defect or fail the ticket.

Elise Carmichael is presenting the session API Testing: How to Write Tests, Integrate into CI, and Track What You're Testing at the STAREAST 2018 conference, April 29–May 4 in Orlando, FL.

Up Next

About the Author

TechWell Insights To Go

(* Required fields)

Get the latest stories delivered to your inbox every month.