Wednesday, July 4, 2018

Adding Methods to Test Cases

The next step in creating a test case, is to add some methods to the test case class.
Each method should assert that one of the known requirements is true.
There are two new methods added in the following example: one to assert that
the table's name is as expected, and the other to assert that the table's group value
is as expected.



 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
[SysTestMethodAttribute]
public void testTableName()
{
  // Verify that the tables name is set correctly.
  this.assertEquals("CustTable", 
  sysDictTable.name());
}
[SysTestMethodAttribute]
public void testTableGroup()
{
  // Verify that the tables group is set correctly.
  this.assertEquals(TableGroup::Main,
  sysDictTable.tableGroup());
}

A test method will typically contain several assertions that are required to hold
true, for the test to be successful.
Note the use of the
assertEquals method. This method, and other assert methods,
are available as part of the SysTestCase framework. These methods also have an
optional string parameter called _message, to specify the message that would go
into the infolog, if the assertion fails. The following is a list of available methods:


Method Description
assertEquals Tests if two values are equal.
assertNotEqual Tests if two values are different.

assertTrue Tests if the value is true.
assertFalse Tests if the value is false.
assertNull Tests if the value is null.
assertNotNull Tests if the value is not null.
assertSame Tests if the objects referenced are the same.
assertNotSame Tests if the objects referenced are not the same.
assertRealEquals Tests if real values differ by the amount specified in
the delta.
assertExpectedInfolog
Message
Tests for an infolog message that is expected.
fail Enables a developer to create custom validation
logic and then call the fail method to integrate with
the Unit Test framework.



Best Regards,
Hossein Karimi

No comments:

Post a Comment

Configure the Firewall on the Enterprise Portal Server

After you install Enterprise Portal, enable Web Server (HTTP) in Windows Firewall. If you do not enable the web server in Windows Firewall...