Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement steps for visual check using image out of file #3043

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

IBrun
Copy link
Contributor

@IBrun IBrun commented Aug 10, 2022

No description provided.

@codecov
Copy link

codecov bot commented Aug 10, 2022

Codecov Report

Merging #3043 (7176eea) into master (eff88e4) will increase coverage by 0.01%.
The diff coverage is 100.00%.

@@             Coverage Diff              @@
##             master    #3043      +/-   ##
============================================
+ Coverage     96.80%   96.81%   +0.01%     
- Complexity     5859     5879      +20     
============================================
  Files           823      825       +2     
  Lines         16622    16679      +57     
  Branches       1076     1076              
============================================
+ Hits          16091    16148      +57     
  Misses          419      419              
  Partials        112      112              
Impacted Files Coverage Δ
.../src/main/java/org/vividus/visual/VisualSteps.java 100.00% <100.00%> (ø)
...rg/vividus/selenium/sauce/SauceConnectManager.java 96.36% <0.00%> (-0.13%) ⬇️
...rm/src/main/java/org/vividus/winrm/WinRmSteps.java 100.00% <0.00%> (ø)
...in/java/org/vividus/winrm/ServerConfiguration.java 100.00% <0.00%> (ø)

📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more


[source,gherkin]
----
When I $actionType baseline with name `$name` from image out of file `$filePath`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

syntax is needed to be discussed, for me it looks a bit awkward

* @param filePath The path to the image file.
*/
@When(value = "I $actionType baseline with name `$name` from image out of file `$filePath`", priority = 1)
public void runVisualTestsUsingImageFile(VisualActionType actionType, String baselineName, String filePath)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public void runVisualTestsUsingImageFile(VisualActionType actionType, String baselineName, String filePath)
public void runVisualTestsUsingImageFile(VisualActionType actionType, String baselineName, Path imageFile)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the same for all other steps

Comment on lines +493 to +496
imageTool.when(() -> ImageIO.read(new File(getImageFilePath()))).thenThrow(new IOException());
assertThrows(UncheckedIOException.class,
() -> visualSteps.runVisualTestsUsingImageFile(VisualActionType.COMPARE_AGAINST, BASELINE,
getImageFilePath()));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extract getImageFilePath() to a local variable


private static String getImageFilePath()
{
return ResourceUtils.findResource(FileSystemBaselineStorage.class, "/baselines/baseline.png").getPath();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return ResourceUtils.findResource(FileSystemBaselineStorage.class, "/baselines/baseline.png").getPath();
return ResourceUtils.findResource(VisualStepsTests.class, "/baselines/baseline.png").getPath();

@valfirst
Copy link
Collaborator

Also, I think it makes to deprecate steps accepting byte[] in this PR

@IBrun IBrun marked this pull request as draft August 10, 2022 13:16
Comment on lines +13 to +14
When I compare_against baseline with name `context` from image out of file `src/main/resources/baselines/context.png`
When I compare_against baseline with name `context` from image out of file `src/main/resources/baselines/context.png` using storage `filesystem`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The steps should work for the absolute path and for the 'resources' (/baselines/context.png))

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm ok with absolute path, but I don't agree for 'resources' as it can confuse users

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants