deployableTest.get().after(this, testMethod, LifecycleMethodExecutor.NO_OP);
}
public void run(final IHookCallBack callback, final ITestResult testResult)
{
TestResult result;
try
{
result = deployableTest.get().test(new TestMethodExecutor()
{
public void invoke(Object... parameters) throws Throwable
{
/*
* The parameters are stored in the InvocationHandler, so we can't set them on the test result directly.
* Copy the Arquillian found parameters to the InvocationHandlers parameters
*/
copyParameters(parameters, callback.getParameters());
callback.runTestMethod(testResult);
// Parameters can be contextual, so extract information
swapWithClassNames(callback.getParameters());
testResult.setParameters(callback.getParameters());
}
private void copyParameters(Object[] source, Object[] target)
{
for(int i = 0; i < source.length; i++)
{
target[i] = source[i];
}
}
private void swapWithClassNames(Object[] source)
{
// clear parameters. they can be contextual and might fail TestNG during the report writing.
for(int i = 0; source != null && i < source.length; i++)
{
Object parameter = source[i];
if(parameter != null)
{
source[i] = parameter.toString();
}
else
{
source[i] = "null";
}
}
}
public Method getMethod()
{
return testResult.getMethod().getMethod();
}
public Object getInstance()
{
return Arquillian.this;
}
});
if(result.getThrowable() != null)
{
testResult.setThrowable(result.getThrowable());
}
// calculate test end time. this is overwritten in the testng invoker..
testResult.setEndMillis( (result.getStart() - result.getEnd()) + testResult.getStartMillis());
}
catch (Exception e)
{
testResult.setThrowable(e);
}