Skip to content
New issue

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

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

Already on GitHub? # to your account

Unit testing #134

Open
Indigo744 opened this issue Nov 22, 2015 · 12 comments
Open

Unit testing #134

Indigo744 opened this issue Nov 22, 2015 · 12 comments

Comments

@Indigo744
Copy link
Collaborator

Hello,
I wonder if we should add some UT to Mapael? That would make the development easier?
A lot of people seems to like QUnit (https://qunitjs.com). Never tried it, but seems good.

Here is some reading:
http://andymatthews.net/read/2012/05/29/Unit-Testing-jQuery-Plugins-with-Grunt-and-QUnit
http://javascriptplayground.com/blog/2012/04/a-jquery-plugin-with-grunt-qunit

@neveldo
Copy link
Owner

neveldo commented Nov 24, 2015

Hello,

I think that Unit tests are always a good practice whatever is the project. It should indeed help us to prevent code regression with the further changes.

However I'm not familar with unit testing with javascript, I'm wondering where to begin with Mapael, and if the functions could be easily testable. In any case, feel free to make proposals for unit testing Mapael if you have enough time !

@Indigo744
Copy link
Collaborator Author

I will try starting something (like instanciating QUnit and building some basic tests). We will build incrementally from that :-)

@neveldo
Copy link
Owner

neveldo commented Nov 25, 2015

It's ok for me, thank you for your help !

@Indigo744
Copy link
Collaborator Author

I found some example of jQuery plugin using UT:
https://github.com/tabalinas/jsgrid
https://github.com/t4t5/sweetalert

I think we should have only one HTML file, with multiple JS files organized as module (http://api.qunitjs.com/QUnit.module).
I suggest to sort these different modules regarding the features:

  • Basic: test default behavior
  • Options: test with some options overriden (callbacks and such)
  • Areas: test with areas
  • Plots: test with plots
  • Links: test with links
  • Legends: test everything regarding the legend
  • Zoom event: test everything regarding the zoom event
  • Update event: test everything regarding the update event

@neveldo
Copy link
Owner

neveldo commented Nov 29, 2015

Thank you, it looks ok to me, I think these modules should cover all the major features of Mapael !

@Indigo744
Copy link
Collaborator Author

At the end, we will also be able to automate these tests using Travis or equivalent!
This kind of tools run each time a PR or commit is made, and tells if the build passed or not (by running the Unit Test suite). You should be able to do this from your GitHub control center.

@neveldo
Copy link
Owner

neveldo commented Nov 30, 2015

Yes this is a very good point as it will contribute to improve the overall quality of the plugin. I will check the integration of travis through GitHub asap.

@neveldo
Copy link
Owner

neveldo commented Nov 30, 2015

I have started to configure automated test (jshint and qunit) through Travis CI :

  • Added Qunit to Grunt config : 753d2b5
  • Added grunt-contrib-qunit to dev dependencies : 59e5692
  • Added .travis.yml file : a7b5976
  • Added travis build information into Readme.md file : bd6c7cf

Build info on Travis : https://travis-ci.org/neveldo/jQuery-Mapael .

It seems there are two remaining fails. However, I get a weird behavior on my machine : each time I run Qunit through grunt test, I get a random number of failed tests ...

@Indigo744
Copy link
Collaborator Author

Woah! So nice!
I think there are some trouble with the setTimeout functions. I got some errors sometimes, and it would pass after some refresh.
I think this is not the proper way to test this behavior. I will look into it and try another approach.

@Indigo744
Copy link
Collaborator Author

We should also integrate a Code Coverage tool in order to monitor our progress on Unit Testing. What do you think?
It exists https://coveralls.io or https://codecov.io which are free for Open Source project.

@neveldo
Copy link
Owner

neveldo commented Dec 9, 2015

Hello,

I agree with you, it's a great idea ! I think I will set up coveralls.io, it seems that it is a lot more documented than codecov.io.

@Indigo744
Copy link
Collaborator Author

Great :) let me know when it is ready!

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

2 participants