Last active
December 19, 2015 15:09
-
-
Save smiklosovic/5974532 to your computer and use it in GitHub Desktop.
Initial idea how to get screenshots in tests, very handy in Arquillian Droidium environment.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RunWith(Arquillian.class) | |
// when this annotation is omitted, images will be saved into | |
// default location, like target/screenshots | |
@SaveScreenShotsTo("target/my-screenshots/ArquillianScreenShooterTestCase/") | |
// when no @TakeScreenShots are specified on method, this one will be used by default | |
@TakeScreenShots(BeforeAsserts.class) | |
public class ArquillianScreenShooterTestCase { | |
@Drone WebDriver driver | |
@Deployment | |
public static Archive<?> getDeployment() { | |
// ShrinkWrap gets deployment | |
} | |
/** | |
* Screenshots will be taken and put into @SaveScreenShotsTo in some format | |
* (e.g.) some target/screenshots/SomeTestCase/test01/screenshot-#.png | |
* where # is a placeholder for a number of screenshot taken in the method. | |
* | |
* Screenshots will be taken before and after the calling of method from Assert class. | |
*/ | |
@Test | |
@TakeScreenShots({BeforeAssert.class, AfterAssert.class}) | |
public void test01() { | |
Assert.assertTrue("some test"); | |
} | |
/** | |
* Just before asserts, annotation of @SaveScreenShotsTo overrides | |
* class annotation when specified. | |
* | |
*/ | |
@Test | |
@TakeScreenShots(BeforeAssert.class) | |
@SaveScreenShotsTo("target/someOtherLocation/") | |
public void test02() { | |
Assert.assertFalse("some test"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'd make it
@TakeScreenShots
instead of@GetScreenShots
. But for everything else +1!