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

[Testing] Adding a snapshot testing framework #165

Closed
1 task done
johnxnguyen opened this issue Jul 24, 2019 · 4 comments
Closed
1 task done

[Testing] Adding a snapshot testing framework #165

johnxnguyen opened this issue Jul 24, 2019 · 4 comments
Labels
testing Issues related to tests

Comments

@johnxnguyen
Copy link
Owner

Please help prevent duplicate requests before submitting a new one:

  • I've searched other open/closed issues for duplicates before opening up this new issue.

Feature Request

Is your feature request related to a problem? Please describe.

The problem I'm having whilst implementing the default styler is how to write clean and concise tests for various formatting scenarios (in particular nested lists). Using standard asserts against the attributed string is cumbersome, verbose, error prone and hard to read.

Describe the solution you'd like

Testing attributed strings is inherently visual and I would argue that snapshot testing is particularly suitable in this case. It would remove the need to inspect attributes which would lead to much cleaner tests. It would also allow us to test formatting of the same markdown string across various screen sizes.

Additionally, we could also use non visual snapshot tests to cover the AttributedStringVisitors output, instead of asserting a long markdown string that contains unicode code points.

I would propose to use swift snapshot testing but am of course open to other frameworks.

I think we should keep dependencies to an absolute minimum, but this dependency would only be added to the test target and I believe it would be of great benefit.

Describe alternatives you've considered

If adding a framework dependency is a no go, then the only alternative we have is to use standard asserts to check the values of attributes (over particular ranges) of an attributed string.

@iwasrobbed
Copy link
Collaborator

I'm 👍 with adding any testing frameworks necessary for proper coverage as long as we keep things simple. Thanks for raising the issue @johnxnguyen

@iwasrobbed iwasrobbed changed the title Adding a snapshot testing framework [Testing] Adding a snapshot testing framework Jul 25, 2019
@iwasrobbed iwasrobbed added the testing Issues related to tests label Jul 25, 2019
@johnxnguyen
Copy link
Owner Author

Damn, so it turns out that swift snapshot testing has a minimum iOS deployment target of 10.0, where as Down is compiling for iOS 9.

One workaround is to bump the minimum iOS version to 10.0 for the test target only. I think I'll do this unless you have any objections.

@iwasrobbed
Copy link
Collaborator

Go for it 👍 Test target can be anything, it's just the built target we try and back support

@iwasrobbed
Copy link
Collaborator

Closed via #177

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

No branches or pull requests

2 participants