[MGNLIMG-114] Tests should output test images in the target folder Created: 09/Jul/13  Updated: 09/Apr/15  Resolved: 13/Mar/15

Status: Closed
Project: Imaging
Component/s: None
Affects Version/s: None
Fix Version/s: 3.2

Type: Improvement Priority: Neutral
Reporter: Magnolia International Assignee: Magnolia International
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
causality
caused by MGNLIMG-100 Loading image from JCR using Abstract... Closed
relation
is related to MGNLIMG-152 Consistency in how test images are ge... Closed
Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Date of First Response:

 Description   

MGNLIMG-100 introduced a test that accidentally wrote test images in src/test/resources. Those images have been accidentally committed to the Git repository.
A lot of tests have (since forever) written images in the root folder of the project, which isn't great either.
We could configure the project as such

<plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
          <systemPropertyVariables>
            <imagesOutputDir>${project.build.directory}/test-images</imagesOutputDir>
          </systemPropertyVariables>
        </configuration>
      </plugin>

Tests should ensure this property is set and fail early if it isn't, or fallback on some default. Tests should ensure they don't overwrite the output of another test. A utility method could be provided to return this directory to a test class/method, suffixed with the test name, for example.



 Comments   
Comment by Magnolia International [ 13/Mar/15 ]

Oh you're right, I forgot I even wrote this
Yes, the implementation tries to be a bit smarter; if the prop isn't set, it uses a default target/test-output, but only if target/ exists. If target/ doesn't exist, then it uses test-output/.

Comment by Magnolia International [ 13/Mar/15 ]

Additionally, I just implemented the "Tests should ensure they don't overwrite the output of another test." bit, which I had also forgotten in my first commit.

Comment by Magnolia International [ 13/Mar/15 ]

This breaks completely when we use the enable-clover profile; clover executes the test a second time, so a bunch of files still exist (those which are created with ignoring the KEEP_GENERATED_FILES_FOR_INSPECTION flag, see MGNLIMG-152)

Comment by Magnolia International [ 13/Mar/15 ]

Now both write() and newOutputFile() methods check the KEEP_GENERATED_FILES_FOR_INSPECTION flag consistently. Partly fixes MGNLIMG-152.

Generated at Mon Feb 12 02:12:25 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.