Opensphere Blog

Regression Tests on Messaging and Webservice
base for integration projects and SOA initiatives.
Simple and with minimal overhead.

Substitution to the rescue!

Are you familiar with the situation where you’re working on on project for many hours and once in a while someone comes by and says that something has changed and you have to go through your entire project and reedit this and that? It happened to me more than once when working on various assignments and I don’t think I have to mention how frustrated it got me each and every time.

No worries, this won’t be happening to you when you start using the variable substitution options implemented in OpenSphere. You only have to click Project -> Substitution Variables... to get started.

Lets say that you have a user and password combination in different places of the project and each combination is the very same so what you should do is create two substitution variables: one being a string type ‘user’ and the other one being password type ‘password’ (this ensures that no one unauthorized will get a hold of the password). Now you have to go through your OpenShpere project (I promise you’ll have to do that only once) and wherever this particular user-password combination is used you simply right-click and select appropriate option from the context menu to paste the substitution string enclosed between two “%” characters (eg. %user%).

And from now on if the authentication parameters are changed for some reason, instead of having to find and change every user-password occurrence all you have to do is update previously defined values in the Substitution Variables dialog.

OpenSphere’s substitution engine supports all different kinds of variable types: string, password, string appender (appends given string each time a substitution occurs), sequence substitution (increments by defined value each time a substitution takes place). There are also more advanced substitution options which allow to replace a given string with a value generated at runtime by executing user provided piece of code which can be either a JavaScript, Java Bean method or a static method. OpehSphere also offers a possibility to get desired values from an xml file. This requires specifying file location (either stored locally or on the internet) and an xpath expression which will allow to precisely locate the value in question separated by the “|” (pipe) character (eg.file:C:/temp/XMLMessage.rvm|xpath://msgField[@name='XMLData']/text()| xpath:/person/firstname/text()).

Some substitution types (string appender, sequence substitution and Java Bean method) requires specifying value reset behavior which determines when the value is reset to default. If set to ‘none’, the default value won’t be reset until the start buttons is pressed. ‘Per test suite’ setting will result in resetting given value each time a test suite is executed. Another option is ‘per test case’ which resets the values whenever a test case is run. And last we have ‘per test step’ which will cause resets every time the test engine starts executing next step.

Sound’s pretty simple, doesn’t it? Cause it is simple and effective and it can save you a lot of time. Go ahead and try it yourself, you will thank me later...

Blog tags: 

User login