use of org.sakuli.actions.TestCaseAction in project sakuli by ConSol.
the class RhinoAspectTest method testDoTestCaseActionLog.
@Test
public void testDoTestCaseActionLog() throws Exception {
initMocks();
BaseActionLoader loader = mock(BaseActionLoader.class);
TestCase sampleTc = new TestCase("test", "testID");
when(loader.getCurrentTestCase()).thenReturn(sampleTc);
TestCaseAction testAction = new TestCaseAction();
ReflectionTestUtils.setField(testAction, "loader", loader, BaseActionLoader.class);
testAction.init("testID", 3, 4, "imagefolder1", "imagefolder2");
assertLastLine(logFile, testAction.getClass().getSimpleName(), LogLevel.INFO, "\"test case [" + sampleTc.getActionValueString() + "]\" TestCaseAction.init() - init a new test case with arg(s) [testID, 3, 4, [imagefolder1, imagefolder2]]");
}
use of org.sakuli.actions.TestCaseAction in project sakuli by ConSol.
the class RhinoAspectTest method testAddActionLog.
@Test(dataProvider = "logLevel")
public void testAddActionLog(LogLevel logLevel) throws Exception {
initMocks();
Report sahiReport = BeanLoader.loadBaseActionLoader().getSahiReport();
final int lisSize = sahiReport.getListResult().size();
final String classContent = "Test-Action-Content";
final String className = TestCaseAction.class.getSimpleName();
final String methodName = "actionMethod";
final String sampleMessage = "sample-message-for-log";
final String arg1 = "ARG1";
final String arg2 = "NULL";
TestCaseAction testAction = mock(TestCaseAction.class);
when(testAction.toString()).thenReturn(classContent);
JoinPoint jp = mock(JoinPoint.class);
when(jp.getTarget()).thenReturn(testAction);
Signature signature = mock(Signature.class);
when(jp.getSignature()).thenReturn(signature);
when(signature.getDeclaringType()).thenReturn(TestCaseAction.class);
when(signature.getName()).thenReturn(methodName);
when(signature.getDeclaringTypeName()).thenReturn(TestCaseAction.class.getName());
when(jp.getArgs()).thenReturn(new Object[] { arg1, null });
LogToResult logToResult = mock(LogToResult.class);
when(logToResult.logClassInstance()).thenReturn(true);
when(logToResult.message()).thenReturn(sampleMessage);
when(logToResult.logArgs()).thenReturn(true);
when(logToResult.level()).thenReturn(logLevel);
RhinoAspect testling = BeanLoader.loadBean(RhinoAspect.class);
testling.addActionLog(jp, logToResult);
assertLastLine(logFile, className, logLevel, "\"" + classContent + "\" " + className + "." + methodName + "() - " + sampleMessage + " with arg(s) [" + arg1 + ", " + arg2 + "]");
verifySahiReport(logLevel.getResultType(), lisSize);
//hide args
when(logToResult.logArgs()).thenReturn(false);
testling.addActionLog(jp, logToResult);
assertLastLine(logFile, className, logLevel, "\"" + classContent + "\" " + className + "." + methodName + "() - " + sampleMessage + " with arg(s) [****, ****]");
//without class values
when(logToResult.logClassInstance()).thenReturn(false);
testling.addActionLog(jp, logToResult);
assertLastLine(logFile, className, logLevel, className + "." + methodName + "() - " + sampleMessage + " with arg(s) [****, ****]");
//without args
when(jp.getArgs()).thenReturn(null);
testling.addActionLog(jp, logToResult);
assertLastLine(logFile, className, logLevel, className + "." + methodName + "() - " + sampleMessage);
//without message
when(logToResult.message()).thenReturn(null);
testling.addActionLog(jp, logToResult);
assertLastLine(logFile, className, logLevel, className + "." + methodName + "()");
}
Aggregations