Best JGiven code snippet using com.tngtech.jgiven.examples.attachments.AttachmentsExampleStage.drawOval
Source: AttachmentsExampleStage.java
...34 public void a_$_oval_circle( String color ) throws IOException {35 addOvalAttachment( 300, 200, getColor( color ), "oval-circle" );36 }37 public void an_oval_circle_as_thumbnail() throws IOException {38 byte[] bytes = drawOval(300, 200, Color.BLUE);39 currentStep.addAttachment(40 Attachment.fromBinaryBytes( bytes, MediaType.PNG )41 .withTitle( "An oval drawn in Java" )42 .withFileName( "oval-circle-as-thumbnail" ));43 }44 private Color getColor( String color ) {45 if( color.equals( "red" ) ) {46 return Color.RED;47 }48 return Color.BLUE;49 }50 private void addOvalAttachment(int width, int height, Color color, String fileName ) throws IOException {51 byte[] bytes = drawOval(width, height, color);52 currentStep.addAttachment(53 Attachment.fromBinaryBytes( bytes, MediaType.PNG )54 .withTitle( "An oval drawn in Java" )55 .withFileName( fileName )56 .showDirectly() );57 }58 private byte[] drawOval(int width, int height, Color color) throws IOException {59 BufferedImage image = new BufferedImage( width, height, BufferedImage.TYPE_INT_ARGB );60 Graphics2D g = image.createGraphics();61 g.setRenderingHint( RenderingHints.KEY_ANTIALIASING,62 RenderingHints.VALUE_ANTIALIAS_ON );63 g.setStroke( new BasicStroke( 10 ) );64 g.setPaint( color );65 g.drawOval( 10, 10, width - 20, height - 20 );66 ByteArrayOutputStream outputStream = new ByteArrayOutputStream();67 byte[] bytes;68 try {69 ImageIO.write( image, "PNG", outputStream );70 bytes = outputStream.toByteArray();71 } finally {72 outputStream.close();73 }74 return bytes;75 }76}...
Check out the latest blogs from LambdaTest on this topic:
The holidays are just around the corner, and with Christmas and New Year celebrations coming up, everyone is busy preparing for the festivities! And during this busy time of year, LambdaTest also prepped something special for our beloved developers and testers – #LambdaTestYourBusiness
Have you ever struggled with handling hidden elements while automating a web or mobile application? I was recently automating an eCommerce application. I struggled with handling hidden elements on the web page.
Agile project management is a great alternative to traditional methods, to address the customer’s needs and the delivery of business value from the beginning of the project. This blog describes the main benefits of Agile for both the customer and the business.
Sometimes, in our test code, we need to handle actions that apparently could not be done automatically. For example, some mouse actions such as context click, double click, drag and drop, mouse movements, and some special key down and key up actions. These specific actions could be crucial depending on the project context.
I think that probably most development teams describe themselves as being “agile” and probably most development teams have standups, and meetings called retrospectives.There is also a lot of discussion about “agile”, much written about “agile”, and there are many presentations about “agile”. A question that is often asked is what comes after “agile”? Many testers work in “agile” teams so this question matters to us.
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!