1. Home
  2. Docs
  3. Tips & Tricks
  4. Variables: ANY and Map data type
  5. How to use Any Type variable

How to use Any Type variable

The any type allows us to assign literally “any” particular value to that variable, simulating what we know as plain JavaScript – where types can dynamically be assigned from different types, such as a String value becoming a Number.

The any type should really be used when we don’t actually know what type is actually coming back to us. This could be, for example, through a function argument that’s part of a third-party library and it doesn’t have any type definitions.

Because the type that is used is not clear beforehand, the AppTester cannot know how to send data to BAW or assert data without telling the AppTester what we should expect. So for the ANY type in the AppTester, the AppTester Expects jSon in which you define the type of variable the any type is at that moment.

In the next table we have examples on how to do that: This table is also available as an Excel download here.

Any Type IBM BAW AppTester input AppTester Assert Note
Default Template

{

“@type”: “String”,
“value”: “”

}

{} ANY type is anonymous type, correct data type is determined in run time so user need to input a data type specifically
Simple Type
(String, Integer, Boolean,…)

//String
tw.local.anyType = “hello”;

//Integer
tw.local.anyType = 10;

//Boolean
tw.local.anyType = true;

// String
{

“@type”: “String”,
“value”: “Hello”

}

// Integer
{

“@type”: “Integer”,
“value”: 10

}

// Boolean
{

“@type”: “Boolean”,
“value”: true

}

// String
“Hello”

// Integer
10

// Boolean
true

– @type is correct data simple type. For example: String, Integer, Decimal, Boolean.
– value is data value
Complex Object

tw.local.profileType = {};
tw.local.profileType.id = “1”;
tw.local.profileType.title = “Developer”;

tw.local.anyType = tw.local.profileType;

{

“@type”: “JobType”,
“value”:

{

“id”: “1”,
“title”: “Developer”

}

}

{
“id”: “1”,
“title”: “Developer”
}
ANY Array

[

{
“@type”: “String”,
“value”: “Hello”
},
{
“@type”: “String”,
“value”: “Hello1”
}

]

Any – Map

{

“@type”: “Map”,
“value”:

{

“key”: 1,
“@type”: “String”,
“value”: “bao test”

}

}

 

Was this article helpful to you? Yes No

How can we help?