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

Include messages while testing signaling conditions #272

Open
3 of 11 tasks
IndrajeetPatil opened this issue Aug 26, 2022 · 3 comments
Open
3 of 11 tasks

Include messages while testing signaling conditions #272

IndrajeetPatil opened this issue Aug 26, 2022 · 3 comments
Assignees
Labels
Beginner-friendly 🤝 Friendly for new contributors Code Style 👩‍💻 Core Packages 📦 Discussion and planning about core packages of easystats

Comments

@IndrajeetPatil
Copy link
Member

IndrajeetPatil commented Aug 26, 2022

Currently, most of the tests that check for signaling conditions (messages, warnings, or errors) are only testing if the conditions occur. But we should be additionally capturing the condition messages to ensure that the condition was produced for expected reasons, and not for some other, unexpected reasons.

expect_error(), expect_warning(), and expect_message() all have a regexp argument for this.

# current
expect_error(f(x))

# should be
expect_error(f(x), "....")

For example, see this test from {datawizard}.

Progress tracker:

  • insight
  • modelbased
  • bayestestR
  • effectsize
  • parameters
  • performance
  • correlation
  • report
  • see
  • datawizard
  • easystats
@IndrajeetPatil IndrajeetPatil added Core Packages 📦 Discussion and planning about core packages of easystats Code Style 👩‍💻 Beginner-friendly 🤝 Friendly for new contributors labels Aug 26, 2022
@strengejacke
Copy link
Member

Note that since we often use format_message(), which wraps lines of the messages to fit to the given width of the console (or whereever the output is streamed to). And the system where tests are run often have different "line length", so never check against the complete string. It's better to have just a few words, the safest is to have just one (key-) word from the message.

@IndrajeetPatil
Copy link
Member Author

Yepp, that's what's happening in {datawizard}; using just a single word or few words in regexp argument.

That said, my personal preference is to use snapshots here to make sure that the messages are formatted and printed as expected, but I know how you feel about snapshot testing 🙃

@strengejacke
Copy link
Member

I know how you feel about snapshot testing

I literally invented them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Beginner-friendly 🤝 Friendly for new contributors Code Style 👩‍💻 Core Packages 📦 Discussion and planning about core packages of easystats
Projects
None yet
Development

No branches or pull requests

6 participants