Passing integer value as String in datatable


#1

Hello,

My dataset has value 27878, that’s passed to a parameter in an action word. So the action word that gets created has a parameter with type int.

Example:
Scenario name: Get student info by stuId of a class

Action word: Get all students by ‘class_no’
class_no == CLASSNO

CLASSNO is data set column which has value 27878.

Java code in eclipse:

public void getallstudentsbyclassno(int stuId) {
}

public void testGetstudentinfobystuIdofaclass() {
    getallstudentsbyclassno(27878);
}

I want the hiptest to treat 27878 as String, I tried with single quotes and double quotes, but booth did not work.


#2

Hello,

When you put numeric characters in a datatable, Hiptest detects automatically that it’s a numeric value. For the moment, it is not possible to chose to use it as a string value. This feature is planned in the Hiptest backlog here: https://trello.com/c/7ldgaDWS/468-when-a-datatable-cell-contains-numeric-characters-then-you-should-be-able-to-specify-if-it-is-a-string-or-an-numeric-value. You can vote for it.

In the meantime, you can override templates used by Hiptest publisher to convert every parameters and variables to string. Find out more about Hiptest publisher customizing: https://hiptest.com/blog/2017/03/02/customising-your-export-with-hiptest-publisher-part-ii-customising-the-templates/

It is pretty easy, for your case, you have to create a folder named templates with these files and their content:

  • booleanliteral.hbs --> {{to_string rendered_children.value }}
  • nullleteral.hbs --> ''
  • numericliteral.hbs --> '{{ rendered_children.value }}'
  • parameterliteral.hbs --> string {{{ camelize_lower rendered_children.name }}}

#3

Thank you for the answer