Skip to content

JITM: Add unit tests for JITM class#7027

Merged
eliorivero merged 5 commits intomasterfrom
add/jitm-unit-tests
Apr 25, 2017
Merged

JITM: Add unit tests for JITM class#7027
eliorivero merged 5 commits intomasterfrom
add/jitm-unit-tests

Conversation

@withinboredom
Copy link
Copy Markdown
Contributor

@withinboredom withinboredom commented Apr 21, 2017

Changes proposed in this Pull Request:

  • Adds unit tests for the Just In Time Message class

Testing instructions:

  • Unit tests should pass

Proposed changelog entry for your changes:

Increase code coverage of unit tests

@withinboredom withinboredom added [Status] Needs Review This PR is ready for review. and removed [Status] In Progress labels Apr 21, 2017
@withinboredom withinboredom requested a review from ebinnion April 21, 2017 18:31
@ebinnion
Copy link
Copy Markdown
Contributor

The tests seem to make sense. The biggest feedback I have is that I would break the tests up.

For example, test_prepare_jitm_edit_comments test seems to actually be testing two separate things:

  1. That the JITM notice displays on edit-comments if Akismet is not active
  2. That the JITM notice does not display on edit-comments if Akismet is not active

While these are very similar, having separate tests might make it easier to grok and know what exactly is failing when a test fails. Same feedback for the other tests.

@withinboredom
Copy link
Copy Markdown
Contributor Author

@ebinnion: I thought about this too, but decided to focus on the rules of a specific view v.s. breaking it up. IOW, if a unit test fails, it fails that JITM, not a specific rule of the JITM. That seemed to be the most intuitive to write. However, I see your point from the view of: "I just wrote code, why did this break?"

I agree that this makes more sense to break up into smaller tests, so I'll go ahead and do that.

@eliorivero
Copy link
Copy Markdown
Contributor

eliorivero commented Apr 24, 2017

I added a testsuite for JITM unit tests so now you can do

phpunit --testsuite jitm

I found one issue when running the tests:

There was 1 failure:

1) WP_Test_Jetpack_JITM::test_jitm_dismiss
Failed asserting that false is true.

/jetpack/tests/php/test_class.jetpack-jitm.php:161

@zinigor
Copy link
Copy Markdown
Contributor

zinigor commented Apr 24, 2017

IDK why, but I couldn't revert changes to yarn.lock properly.
I have fixed the failing test and added an example of how we can add explanation strings to make failures more obvious.

@eliorivero eliorivero force-pushed the add/jitm-unit-tests branch from 38e1926 to aa32052 Compare April 24, 2017 23:56
@eliorivero
Copy link
Copy Markdown
Contributor

I've successfully reverted the yarn.lock and tested again and with Igor's fix the test now passes.
So let's 🐑

@eliorivero eliorivero added [Status] Ready to Merge Go ahead, you can push that green button! and removed [Status] Needs Review This PR is ready for review. labels Apr 24, 2017
@eliorivero eliorivero merged commit 4d102e7 into master Apr 25, 2017
@eliorivero eliorivero deleted the add/jitm-unit-tests branch April 25, 2017 01:21
@eliorivero eliorivero removed the [Status] Ready to Merge Go ahead, you can push that green button! label Apr 25, 2017
@eliorivero eliorivero added this to the 4.9 milestone Apr 25, 2017
jeherve added a commit that referenced this pull request Apr 25, 2017
eliorivero pushed a commit that referenced this pull request Apr 25, 2017
* Changelog: initial commit for 4.9 release.

* Changelog: add #6929

* Changelog: move old changelogs to changelog.txt

* Readme: restore deleted release post link.

The post is now live.

* Changelog: add #6853

* Changelog: add #6856

* Changelog: add #6857

* Changelog: add #6884

* Changelog: add #6885

* Changelog: add #6892

* Changelog: add #6894

* Changelog: add #6898

* Changelog: add #6899

* Changelog: add #6900

* Changelog: add #6909

* Changelog: add #6927

* Changelog: add #6947

* Chagelog: add #6958

* Changelog: add #6961

* Changelog: add #6963

* Changelog: add #6965

* Changelog: add #6986

* Changelog: add #7000

* Changelog: add #7013

* Changelog: add #7015

* Changelog: add #7019

* Changelog: add #7028

* Changelog: add #6998

* Changelog: add #6999

* Changelog: add #7044

* Changelog: add #6881

* Changelog: add #6922

* Changelog: add #6940

* Changelog: add #6962

* Changelog: add #6942

* Changelog: add #6959

* Changelog: add #7018

* Changelog: add #6948

* Changelog: add #6657

* Changelog: add #7030

* Changelog: add #7048

* Changelog: add #7031

* Changelog: add #6990

* Changelog: add #6957

* Changelog: add #7027
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants