I have Maven and Testing tools on my project. I and I am trying to add screenshots to allocating reports. If I call the method with "Attachment" annotations directly from my test, then everything is fine.
But if I call it in the "@Efter Matthews" section, then screenshots are added to the wrong report and mixed.
In both cases, screenshots are generated and saved on disk correctly.
I have already seen the question here:
And I think, due to the TestGen adapter, my difficulties can be.
Call the "Attachment" method What is the right way to do it? What adapter do I use to avoid this problem? Maybe somebody gave me examples of using iTestListener to make screenshots, if a test failed? I have a similar problem with temptation + testNG and it IHookable interface by my BaseTest class. << / P>
Javadoc says that:
() method will be applied instead of every @ test method The test method will be invited on the greeting of callback () method of the IHookCallBack parameter.
The code snippet looks like this:
Public Class Bestset IHookable {@Override Public Zero Run (IHookCallBack call back, ITestResult testResult) {callBack.runTestMethod ( TestResult); If (testResult.getThrowable ()! = Null) {try {takeScreenShot (testResult.getMethod (). GetMethodName ()); } Hold (IOException e) {e.printStackTrace (); }} Attachment (value = "method {0} failure, type =" image / PNG ") private byte [] Lace screenshot throws IOException {get getWebDriver (). GetScreenshotAs (Output Type. BYTES);} }
Note that you can not use testResult.isSuccess (), yet, because the result of the test method is unknown and at that time it has a "running" status < / P>
No comments:
Post a Comment