Apigee Proxy - XML based | Code Coverage and Unit testing approach | Best Practices

Hi ,

Can anyone please help me to understand the approach and best practices to write unit test for the apigee proxy developed as XML based. I want my build and source code to be tied with sonar to test the code coverage . please suggest any reference for this.

Note - I am just new to apigee world.

Thanks ,

Patty

0 6 923
6 REPLIES 6

akoo
New Member

Hi @pattysap,

The best practice is to treat unit testing on Edge as testing 1 of 3 things:

1) 3rd-party systems your API calls rely upon (e.g., IDP, syslog)

2) Difficult to simulate scenarios, e.g. timeouts, 500 errors, testing IP blacklisting

3) script callouts (e.g., Java, JS, Python script callouts that you can test in isolation)

It is an anti-pattern to test individual XML policies, themselves. Leave that to Apigee's engineers/testers to handle that for you.

I think it's also worth mentioning you may want to consider testing groups of policies, esp. when they contribute to a specific functionality (e.g., encrypting a particular field in the request). Though isolating policies to test is not easy at this time, it is something you may wish to explore further.

Does this help?

Best,

-Alex

Hi @pattysap

Welcome to the community !!!

As @Alex Koo mentioned, you don't need to test the XML policies but if you want to test some custom logic, that is - the conditions you have used within the proxy or see if a policy was called or check if the variable has been set with the correct value, check this out.

Not applicable

I am not aware of any Sonar compatible configuration analyzers for Apigee, though there is some interest. You may want to look at in development tools like https://github.com/apigeecs/bundle-linter (a bit of a plug for community participation)!

Hello,

I'm working on a SonarQube plugin. See here for more informations : https://community.apigee.com/articles/49758/apigee-sonar-plugin.html

Hi,
I want to check the code coverage of apiproxy.
I have installed the sonar plugin.Also made the sonar-way-apigee as default profile.
Can someone please help me with following questions.
1.How to write junit test cases for apiproxy?
2.How to check the apigee proxy code coverage using sonar apigee plugin?

hi, please don't ask new questions as replies to 5-year old threads! The answers get lost! 

Ask a new question.