APICKII tests replace basepath host name based on env dynamically

Hi,

Referring to the article to add

https://community.apigee.com/articles/26716/api-proxy-team-development-with-maven.html

I am trying to add in my integration tests of api-ckli base-path as a dynamic variable ( example scenario in features file)

Given I set Content-type header to application/json When I GET base-path/5656

Currently, the entry is -

Given I set Content-type header to application/json When I GET /customers/v1/5656

Similarly, i would also need to use domain variable instead of hardcoded paths

"domain":"demo-test.apigee.net"

Before(function() {

this.apickli = new apickli.Apickli('https', 'demo-test.apigee.net);

The author is suggesting to create config.json something like that -

{"myproxy":{"domain":"demo-test.apigee.net","basepath":"/customers/v1"}}

But, how can we make it environment specific as configurations e.g domain may change based on environment. Also, how can we inject/read this dynamic variable basepath in features. Do we need a hook per testcase as base-path can have a prefix too or could simply be /customers/v1.

Also, in maven plugin we have a config.json with environment-entries can they be applied on unit/integration tests.

Anyone implemented this or any have any experience please share your inputs.

thanks.

0 1 228
1 REPLY 1

Hi @Aakash Sharma,

I do this using the Maven "maven-resources-plugin" and "replacer" plugins.

I use it on the Apickli config file "test-config.json" to replace a token "API_NORTHBOUND_DOMAIN" with value in the "${api.northbound.domain}" property from the Maven profile. Then in "init.js" I use:

module.exports = function() {
    this.Before(function(scenario, callback) {
        this.apickli = new apickli.Apickli('https', config.apiconfig.domain + config.apiconfig.basepath);
	...        

You can see an example of this here: https://github.com/kurtkanaskie/pingstatus-v1

See the "pom.xml", "test/integration/test-config.json" and "test/integration/features/step_definitions/init.js" files.

Hope that helps.