Tricentis Tosca 16.0 Released on Feb-2023 ----- UFT has been upgraded from UFT 15.0.1 to UFT One 15.0.2, Beginning at November 2020.

Wednesday, 21 August 2024

What is the difference between CALC & MATH functions in Tosca?

CALC

The Calc function in Tosca is designed for basic arithmetic operations. It’s a straightforward tool that enables you to perform simple mathematical calculations directly within your test steps or templates. This function is primarily used when the operations required are basic and don't involve complex mathematical logic.


Features:
Simple Arithmetic Operations: Calc supports addition, subtraction, multiplication, and division.
Ease of Use: The syntax for Calc is intuitive and similar to how you would write a basic math expression on paper.
Integration with Variables: You can use Calc to perform operations on Tosca buffers, test data values, constants, or a combination of these.

Example:
Suppose you have a scenario where you need to calculate the total price of items in a shopping cart. The price of each item and the quantity are stored in buffers. You can use Calc as follows:

TotalPrice = {B[Item1_Price]} * {B[Item1_Quantity]} + {B[Item2_Price]} * {B[Item2_Quantity]}


MATH

The Math function in Tosca is a more advanced and versatile tool compared to Calc. It allows you to perform a wide range of mathematical operations beyond simple arithmetic, including trigonometry, logarithms, exponential functions, and more. Math is useful when your test case requires complex calculations that involve multiple steps or sophisticated mathematical functions.

Features:
Advanced Mathematical Operations: Includes trigonometric functions, powers, logarithms, square roots, and more.
Flexible and Powerful: Allows for more intricate calculations and can handle complex mathematical expressions that go beyond basic arithmetic.
Support for Multiple Functions: You can chain multiple mathematical operations within a single expression.

Example:
Imagine you are testing a scientific calculator application and need to verify that it correctly computes the square root of a number, then raises that result to the power of 3:

Result = Math.Pow(Math.Sqrt({B[Value]}), 3)