ColdFusion Summit Notes: Testing Automation, Luis Majano
October 17, 2016
Most companies - do a little bit of tests, claim it’s automated, but in reality the test plan is pretty bad
why people don’t test
think they’re too busy
“you don’t have time to test, you need to deliver now”
sometimes it’s comfort - don’t feel comfortable applying testing methodologies
afraid
- it’s new
- new learned behavior
TDD / BDD is a behavior that is LEARNED
Biggest lie in software dev: don’t worry, we’ll create the tests and refactor later
Time is money - how do you value your time?
if you don’t apply testing methodologies you pay a price
usually that price is “time”
No more excuses
yes it will hurt a little at first
but big benefits
it’s a learned behavior
will accelerate your development
some people think it’s counterintuitive, that writing tests takes longer
that’s a lie
maybe at first while you’re learning the tools
but longer term, it makes everything faster
Automation —
TDD /BDD = a process
always looking for continuous improvement / delivery
tools for automation -
FIRST: you HAVE to write some tests
TestBox & CommandBox
From CommandBox: install testbox saveDev
You get:
APIdocs for Test Box
Core
a test browser (small app that browses a directory for tests)
a vanilla test harness that runs your tests whether you used a framework or not
test runner
samples
Test Harness includes —
Automated test results
xUnit/BDD test bundles
Harness bootstrap
- needs its own Application.cfc. Lives in a separates space than the real CF app. So you basically need to copy/paste everything from your app’s Application CFC into here for the tests to run.
HTML Runner
ANT Runner
Test Bundle CFC
just a CFC
inherits from a base spec CFC
will execute the tests
Run tests
easiest way is just http://localhost/tests/bundle.cfc?method=runRemote
that’s not the only way
can use soap runner, http, REST, NodeJS, CommandBox, Custom Runner
Developer Testing —
how to automate?
[demo of commandbox + testbox]
NodeJS testbox-runner
to do all the testing from Node.js
(TODO: could i use this to add testing to my DataHashSet.js project? and call it from the gulp file?)
Automation for testing as a developer
(using Grunt, task runner for Node)
ColdBox Elixir
Node project
help dev’s who are not very familiar with Node to integrate asset pipelines, minify via SASS or LESS, etc.
intent: to help CF dev’s get more into UI development
Continuous Integration
start w/ source control (git, subversion)
have a process that monitors the source control
if code is pushed to a particular branch, some process occurs (run a test, run a command, etc)
Various options for CI servers:
Travis CI
Jenkins
Atlassian Bamboo
TeamCity
GitLab
Getting started w/ Jenkins is extremely easy, takes 2 commands (with CommandBox):
wget http://site/jenkins.war
box server start warpath=jenkins.war
CommandBox will load up Jenkins and start a server for you
Jenkins - easy to set up, but not easy to configure. Thousands of plugins lots of things to dial in.
BUT it works fantastic once it’s running.
Travis CI
open source
can connect it via your github account
activate it for your repos
create .travis.yml
commit the file to the repo
Applying tests to an app that’s already built it difficult
May end up rebuilding the app
will find you can’t test your app in its current state
If you’re starting from scratch it’s a lot simpler.
CFSilenium project, and there is a (not yet released) Ortus fork of that
Also look at “Web Driver” as that’s the main thing that’s supported now