How to implement a Tmar test in Jspresso?

123 Views Asked by At

Following the www.tmar-test.com installation procedure, I wrote a very basic test (arithmetic sum) in my Jspresso application and all is OK.

In a second step, I would like to write a more realistic test and call a method that is part of my Jspresso application.

I need to initiate the test description context in order to call the method, but I lack of information.

Do you have a snippet to help me ?

As example, based on Hrsample, could you provide a Tmar method calling the computeAge method ?

Below the computeAge method :

package org.jspresso.hrsample.model.service;
import java.util.Date;
import org.jspresso.hrsample.model.Employee;
import org.jspresso.framework.model.component.service.IComponentService;
/**
* The services delegate of the Employee entity
*/
public class EmployeeServiceDelegate implements IComponentService {
/**
* Computes the employee age.
*
* @param employee
* the employee this service execution has been triggered on.
* @param birthDate
* a birth date (might be different than the actual employee birth
* date).
* @return the age computed from the birth date passed as parameter.
*/
public Integer computeAge(Employee employee, Date birthDate) {
if (birthDate != null) {
return new Integer(
(int) ((new Date().getTime() - birthDate.getTime()) / (1000L * 60 * 60 * 24 * 365)));
}
return null;
}
}
1

There are 1 best solutions below

1
On BEST ANSWER

Look this post at Jspresso.org which should help you.