1 package org.testng.internal; 2 3 import java.io.Serializable; 4 5 import org.testng.IInvokedMethod; 6 import org.testng.ITestNGMethod; 7 import org.testng.ITestResult; 8 9 public class InvokedMethod implements Serializable, IInvokedMethod { 10 private static final long serialVersionUID = 2126127194102819222L; 11 transient private Object m_instance; 12 private ITestNGMethod m_testMethod; 13 private Object[] m_parameters; 14 private long m_date = System.currentTimeMillis(); 15 private ITestResult m_testResult; 16 InvokedMethod(Object instance, ITestNGMethod method, Object[] parameters, long date, ITestResult testResult)17 public InvokedMethod(Object instance, 18 ITestNGMethod method, 19 Object[] parameters, 20 long date, 21 ITestResult testResult) { 22 m_instance = instance; 23 m_testMethod = method; 24 m_parameters = parameters; 25 m_date = date; 26 m_testResult = testResult; 27 } 28 29 /* (non-Javadoc) 30 * @see org.testng.internal.IInvokedMethod#isTestMethod() 31 */ 32 @Override isTestMethod()33 public boolean isTestMethod() { 34 return m_testMethod.isTest(); 35 } 36 37 @Override toString()38 public String toString() { 39 StringBuffer result = new StringBuffer(m_testMethod.toString()); 40 for (Object p : m_parameters) { 41 result.append(p).append(" "); 42 } 43 result.append(" ").append(m_instance != null ? m_instance.hashCode() : " <static>"); 44 45 return result.toString(); 46 } 47 48 /* (non-Javadoc) 49 * @see org.testng.internal.IInvokedMethod#isConfigurationMethod() 50 */ 51 @Override isConfigurationMethod()52 public boolean isConfigurationMethod() { 53 return m_testMethod.isBeforeMethodConfiguration() || 54 m_testMethod.isAfterMethodConfiguration() || 55 m_testMethod.isBeforeTestConfiguration() || 56 m_testMethod.isAfterTestConfiguration() || 57 m_testMethod.isBeforeClassConfiguration() || 58 m_testMethod.isAfterClassConfiguration() || 59 m_testMethod.isBeforeSuiteConfiguration() || 60 m_testMethod.isAfterSuiteConfiguration(); 61 } 62 63 /* (non-Javadoc) 64 * @see org.testng.internal.IInvokedMethod#getTestMethod() 65 */ 66 @Override getTestMethod()67 public ITestNGMethod getTestMethod() { 68 return m_testMethod; 69 } 70 71 /* (non-Javadoc) 72 * @see org.testng.internal.IInvokedMethod#getDate() 73 */ 74 @Override getDate()75 public long getDate() { 76 return m_date; 77 } 78 79 @Override getTestResult()80 public ITestResult getTestResult() { 81 return m_testResult; 82 } 83 } 84