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

Empty .snap files when class has no tests #47

Closed
idalreadyinuse opened this issue Nov 18, 2020 · 3 comments
Closed

Empty .snap files when class has no tests #47

idalreadyinuse opened this issue Nov 18, 2020 · 3 comments

Comments

@idalreadyinuse
Copy link

When a class does not have a test within it, an empty .snap file gets generated regardless. This can happen when using the @Nested annotation in junit5. As an example:

@ExtendWith({SnapshotExtension.class})
class SnapshotDemoApplication {
  @Nested
  class NestedClass {
    @Test
    void nestedTest() {
      SnapshotMatcher.expect("hello").toMatchSnapshot();
    }
  }
}

Will generate 2 .snap files:

  • SnapshotDemoApplication.snap (this has nothing in)
  • SnapshotDemoApplication$NestedClass.snap (with stuff in)

java-snapshot version: 2.0.0-Beta6
junit-jupiter: 5.6.3

Just wondering is this expected behaviour? We are currently working around it by just ignoring those files but it is becoming a bit of a pain.

Many thanks

@jackmatt2
Copy link
Member

This should be resolved once all items in #44 are done. @juja0 FYI

@idalreadyinuse
Copy link
Author

That's great. Thanks.

@idalreadyinuse
Copy link
Author

@jackmatt2 - I have just tested this against 2.1.0 and empty .snap files still seems to be created. With the example above I get an empty SnapshotDemoApplication.snap file.

Thanks

@jackmatt2 jackmatt2 reopened this Nov 29, 2020
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

No branches or pull requests

2 participants