FamilySearch/gedcomx-php

Faster test suite?

Closed this issue · 8 comments

Functional tests are awesome but 45 minute test suites are not. Is there any way to decrease the time it takes to run the tests?

+1 - Currently, the tests run live integration tests against the Sandbox. There must be a better way.

Ruby has a gem called VCR that will record HTTP requests to be replayed later, which works great for testing so that you don't have to mock everything out. PHP has a port of that library: http://php-vcr.github.io

It has the following disclaimer, "Disclaimer: Doing this in PHP is not as easy as in programming languages which support monkey patching – this project is not yet fully tested, so please use at your own risk!"

I don't know, still might be worth taking a look at.

Tests should run fast enough to give rapid feedback. Otherwise, Test First doesn't really work.

I've got PHP VCR working except that it fails on the POST version of OAuth2 authorization. I don't know why. It even fails when recording. The server responds with an error that only occurs when the Content-Type header is missing, but it's not.

If I can see the raw requests to compare the version with VCR recording (which fails) and the version without VCR (which passes) then I might be able to figure out what's going on.

I've installed mitmproxy to setup a local transparent proxy to monitor HTTPS traffic but can't seem to get working.

I got mitmproxy working. It reveals that VCR is not sending the POST body.

I have an issue open against PHP VCR and a PR for failing test cases. I tried diagnosing the problem but wasn't able to make much headway.

Any other option (such as Guzzle middleware) will require a ton of work so I would prefer to get PHP VCR working.

adri commented

Hey Justin, What is the exact request that is failing? Maybe I can help.

@adri Thanks for dropping in. The failing test is testInitiateAuthorizationPost in tests/functional/AuthenticationTests.php. Under the covers it uses Guzzle version 3.

adri commented

@justincy Thanks, is there already a branch using php-vcr?

@adri There's a branch in my fork called phpvcr.