You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "kpouer (via GitHub)" <gi...@apache.org> on 2023/02/06 21:32:37 UTC

[GitHub] [commons-imaging] kpouer commented on a diff in pull request #271: Unit test : make tests in memory instead of writing hundred of tmp files

kpouer commented on code in PR #271:
URL: https://github.com/apache/commons-imaging/pull/271#discussion_r1097942535


##########
src/test/java/org/apache/commons/imaging/formats/bmp/BmpRoundtripTest.java:
##########
@@ -140,17 +139,21 @@ private void writeAndReadImageData(final int[][] rawData) throws IOException, Im
 
         final byte[] bytes = Imaging.writeImageToBytes(srcImage, ImageFormats.BMP);
 
-        final File tempFile = Files.createTempFile("temp", ".bmp").toFile();
-        FileUtils.writeByteArrayToFile(tempFile, bytes);
-
         final BufferedImage dstImage = Imaging.getBufferedImage(bytes);
 
-        assertNotNull(dstImage);
-        assertEquals(srcImage.getWidth(), dstImage.getWidth());
-        assertEquals(srcImage.getHeight(), dstImage.getHeight());
-
-        final int[][] dstData = bufferedImageToImageData(dstImage);
-        compare(rawData, dstData);
+        try {
+            assertNotNull(dstImage);
+            assertEquals(srcImage.getWidth(), dstImage.getWidth());
+            assertEquals(srcImage.getHeight(), dstImage.getHeight());
+
+            final int[][] dstData = bufferedImageToImageData(dstImage);
+            compare(rawData, dstData);
+        } catch (final Throwable e) {
+            final Path tempFile = Files.createTempFile("temp", ".bmp");
+            Files.write(tempFile, bytes);
+            System.err.println("Failed tempFile " + tempFile);

Review Comment:
   Hi, in fact I could undo the change that automatically write the tmp file as it is probably useless in case of automatic tests. But add back the code that writes the file but commented out so it could be activated manually by a developper if needed ?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org