how to write unit test cases for form display methods

I have customised methods on the populated grid of a form

I want to write unit test cases for those methods

is it possible? if yes How?

thanks in advance

Access to code in forms is cumbersome - make your life easier and move the code to a class. Then test it as usual.

Thanks for the reply Martin. It helped me in some display method

but every timeI write the test case this way

[SysTestMethodAttribute]

public void abc()

{

this.assertEquals(currentvalue, method with parameters)

}

but this currentvalue has to be real if I use “str” or int value in that currentvalue (the value i am expecting from the method)field, the test case is not succeeded

Still I have two display methods in which there is str and table a return type so how to convert these into real types in the class method which i will be forming so that my test cases should succeed

About currentValue - if the return value is a real, declare currentValue as a real as well. What’s the problem? It’s completely up to you what value will you provide as the expected result. An example:

real expected = 0.5;
this.assetEquals(expected, 1/2);

If you use a string, the comparison will always fail, because the types are not compatible. It does work with int, though.

Also, you may get into some troubles when using equality with real numbers and you may want a less strict check:

this.assertEquals(1.00, 1.000000000001); // fails
this.assertRealEquals(1.00, 1.000000000001, 0.0000001); // succeeds

Then you wrote: “I have two display methods in which there is str and table a return type so how to convert these into real types”. But if your method returns a string, why would you write a test that expects a real? The same is true with a table, you’ll just probably need several assertions to check values of all fields you’re interested in.