#100DaysOfCode - Week07
In my seventh week of the #100DaysOfCode Challenge, I was able to combine two categories of coding in an interesting way. I've been working on web application development, and I've separately been working on automation. Practicing some Test-Driven Development, however, I built an automated testing bot for a web application in progress.
The Web App
The web application project is a To-do List using a Django web application framework, which is the same framework I've been working with for a couple weeks now. I've written a few automated tests for web applications in previous weeks, but in practicing a Test-Driven Development (TDD) approach, the number of tests has increased and the tests are more granular. TDD can be summed up as follows:
- Write an automated test of what you want to build,
- write just enough code to pass that test,
- refactor (improve) the code, if needed, and repeat.
TDD requires more coding than just building an app because of all the test writing that is required. But the extra effort is worth it because it's a great insight into Agile, which is closely associated with TDD. The tests I was writing this past week included unit tests (tests of the code from the programmer's perspective) and functional tests (tests of the code from the user's perspective).
The Testing Bot
The testing bot (I'm using the term "bot" here to refer to an automation of tasks normally done by a human) was built using Selenium to automate activity in a web browser. For example, when you're building a web page with a form on it, one way to test that would be for a human to open up a web browser, put something in the form, and then submit the form and make sure the expected result occurs. But a bot can do the same thing in a way that's more scalable.
Below is the short video that shows me running a quick series of automated unit tests and then a series of automated functional tests. The unit tests are performed in the command line, but the functional test is being performed by the bot. The bot opens a web browser, inputs text very quickly and submits the form, and then repeats another form submission.
At this point I'm nearly halfway done with the 100 days of the challenge, and it's surprising how much can be learned in that amount of time. What's not surprising is the number of things I want to automate now!
Rob Valdez, CPA, CISA, CISM, is a risk advisory services manager in Kaufman Rossin’s Boca Raton, Florida, office and provides technology consulting services, including PhishNet by Kaufman Rossin, a security awareness training service. Rob can be reached at rvaldez@kaufmanrossin.com.