Random Data Generator
A full-featured random data generator is shipped with T.apex. We can use this random data generator to generate test data.
In test code, we can do this:
String s = (String)T.create('String');
And this will generate a random string for us.
Also we can use below, which is equivalent to the above.
String s = (String)Random.anyString.run();
Random
is just the random data generator in T.apex. Note that T
can only be used in test codes, while Random
is just a utility class and can be used anywhere outside test codes.
Therefore, if we want to generate random data outside test codes, please use the latter form.