Sorry for the typos - I was on my phone and accidentally hit send.
I’m not looking at my code at the moment, but I think I leaned towards queryParam because of URLEncoding. Plus, the query params list is just loads easier to read than a long url.
I wanted to add a few more notes on integration tests vs load testing.
So load testing is, obviously, about bringing load against a web app. To do that most effectively, you want to bring in a lot of different requests. And you’d like to mimic user behavior. This is why Feeders and options beyond just execing an http request (e.g. random switch, pause, if-else, etcc) are so good.
With integration testing, you define a scenario ahead of time that you want to be executed more-or-less as-is with as little variability as possible.
For example, there should be no (or very little) variability in the steps taken. Thus random switching, if-else’s, etc aren’t really useful.
- I have been thinking about introducing groups, though, for readability.
- I place pauses as a matter of course after anything not a get, though I can foresee the possibility of needing to override that in the future.
- Right now, 200 ms is ample time for back-end replication to occur so that secondary reads produce the correct results.
Variability, if there is to be any, should be data-variability. Feeders are a bit overkill here because simply defining your data including variability prior to test creation is sufficient and more readable. Also, the variability is more easily reflected in the documentation (e.g. scenario name and test step names) so that if there are failures, some of the key features of the failure are immediately available.
And, I mean, come on. This is just sexy:
createTest(“Gimme a test”,
step(“Login user”, true, “/login”, “post”, new StringBody("""{“user”:“scott”,“password”:“tiger”}"""),
step(“Check preferences”, false, “/profile/preferences”, checks = List[HttpCheck](
jsonPath("$.username").is.(“scott”),
jsonPath("$.theme_id").ofType[Int].is.(1)
)),
step(“Logout”, true, “/logout”, “post”),
step(“Check logout”, false, “/profile/preferences”, stat = 401)
)
It’s just tight code.
My current integration suite is about 400 test steps in its most rigorous test-case. When everything is right, that entire suite runs in less than a minute (when you account for dependency download and compilations). And the nice thing is, as I add more tests, I don’t anticipate the time to run to increase very much. Whereas with other suites that my team had used previously, it would always take integration tests minutes to run because nothing was parallelized.
I also have a sub-set of tests from it that we use for smoke testing which I find to be a nice perk.