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

add tests for the struts2-jquery-plugin tags #90

Closed
sdutry opened this issue Dec 22, 2016 · 29 comments
Closed

add tests for the struts2-jquery-plugin tags #90

sdutry opened this issue Dec 22, 2016 · 29 comments
Assignees
Milestone

Comments

@sdutry
Copy link
Contributor

sdutry commented Dec 22, 2016

Seeing that it's usualy difficult and time-consuming to test every single tag in isolation, I thought it might be a good idea to have some integration-tests for the tags.

This way, it should be easier to detect problems when they occur.

I've made a small POC for a simple case, illustrating that it's possible.
struts2-jquery-tests
Edit:

  • this assumes to have struts2-jquery version 4.0.2-SNAPSHOT installed
  • to run use: mvn verify

The eventual idea would be to:

  • have a seperate module in the project which runs the integration tests
  • have tests for each tag
  • have tests for each functionality of the tags

If there's problems you can think off now for this approach, please let me know.

Please let me know your thoughts on this, so that i know if i should put effort in it or not.

@lukaszlenart
Copy link
Member

Did you try to run this with Travis-CI?

@sdutry
Copy link
Contributor Author

sdutry commented Dec 22, 2016

@lukaszlenart
No i did not.

What happens here when running the mvn verify is the following:

  • local jetty-server is started
  • tests use the platform independent HtmlUnitDriver to call the Urls and perform the tests
  • local jetty-server is stopped

I currently have no experience with Travis-CI.
Could you please:

  • name the big steps that happen
  • point me towards the documentation
  • point me toward a project which i could use as an example?

I also have no idea what the build server is that this project uses.

@sdutry
Copy link
Contributor Author

sdutry commented Dec 22, 2016

@lukaszlenart
I managed to get this POC project onto Travis-CI.
see: struts2-jquery-tests

@lukaszlenart
Copy link
Member

Cool, it passes so it's a way to go 💯

@sdutry
Copy link
Contributor Author

sdutry commented Dec 23, 2016

@lukaszlenart
If i understand correctly, you're suggesting the following:

  • adding the tests as a module
  • adding the project to Travis-CI so it runs with every commit / pull-request

Am I correct in assuming that only someone with admin rights can add the project to Travis-CI?
(which means I'll probably have to contact @jogep for this)

Thx in advance for the info.

@lukaszlenart
Copy link
Member

Yes and yes, only repo owner can setup build on TravisCI but that's easy :)

@sdutry sdutry self-assigned this Dec 23, 2016
@sdutry
Copy link
Contributor Author

sdutry commented Dec 23, 2016

links to work in progress:

@sdutry sdutry changed the title add tests for the struts2-jquery tags add tests for the struts2-jquery-plugin tags Dec 24, 2016
@lukaszlenart
Copy link
Member

Did you open a PR? Could you add Travis badge?

[![Build Status](https://travis-ci.org/sdutry/struts2-jquery.svg?branch=issue90)](https://travis-ci.org/sdutry/struts2-jquery)

@sdutry
Copy link
Contributor Author

sdutry commented Dec 26, 2016

@lukaszlenart
I didn't open a pull request yet.
(was going to add more tests with more tags first)

From the information i can find about the Travis badge, i conclude the following:

  • should be added to the README.md
  • should be done with the actual url (and not the one from my fork, since that would be wrong once it's merged)

@lukaszlenart
Copy link
Member

I think starting even with one test is a good idea, tests for other tags can be added step-by-step with additional PRs :)

Regarding the badge: right, I was too eager :)

@sdutry
Copy link
Contributor Author

sdutry commented Dec 26, 2016

@lukaszlenart
Ok,

I will just add the last test i wanted to add for the sj:a tag and make a pull request after that.

Thx for the advice so far concerning Travis-CI.

@jogep
Copy link
Contributor

jogep commented Dec 29, 2016

I setup travis for the struts2 jquery plugin:
https://travis-ci.org/struts-community-plugins/struts2-jquery

Is there anything I need to care about it?

@sdutry
Copy link
Contributor Author

sdutry commented Dec 29, 2016

@jogep
i noticed and added the badge to the README.md file (in the pull request) so it shows the build status on on the github pages.

Now we should easily spot when a pull request or commit is made that breaks the build.

  • all checks have passed for a pull request => referencing the exact build for the pull request on Travis-CI
  • the status icon on the master branch inside the README.md

@jogep
Copy link
Contributor

jogep commented Dec 30, 2016

@sdutry Only problem what I can see that we currently not developing against master branch. Usually I create for each new release a new branch which is merged into master when the release is finished. Maybe we need to change the process here.

@sdutry
Copy link
Contributor Author

sdutry commented Dec 31, 2016

@jogep
What i could do is to change the status badge to monitor the release/4.0.2 branch and add an indication in the README.md that it's for that branch (so we don't forget or can add more status badges the further we get).

@sdutry
Copy link
Contributor Author

sdutry commented Dec 31, 2016

@jogep
I've switched the badge to monitor release/4.0.2
see: branch

thx for pointing this out.

@jogep
Copy link
Contributor

jogep commented Jan 8, 2017

Great can we merge this in latest release/4.0.3 branch?

@sdutry
Copy link
Contributor Author

sdutry commented Jan 8, 2017

@jogep
I'll check to make a pull request to that branch.

Give me a minute to figure out what exactly needs to be done.

@sdutry
Copy link
Contributor Author

sdutry commented Jan 8, 2017

@jogep
Is it possible that the version in the pom on the branch release/4.0.3 still needs to be updated to 4.0.3-SNAPSHOT ?

@sdutry
Copy link
Contributor Author

sdutry commented Jan 9, 2017

checklist for tags to add tests for

  • sj:a
  • sj:div
  • sj:submit
  • sj:checkboxlist
  • sj:radio
  • sj:select
  • sj:accordion (+ sj:accordionItem)
  • sj:autocompleter
  • sj:dialog
  • sj:menu (+ sj:menuItem)
  • sj:progressbar
  • sj:slider (if i find a way to test it) (currently not possible with basic htmlunit-driver)
  • sj:spinner (if i find a way to test it)
  • sj:tabbedpanel (+ sj:tab)
  • sjg:grid
  • sjdt:datatables
  • sjt:tree (+ sjt:treeItem)

all these checkboxes currently are things for which i should be able to find a way to test.

If there's more suggestions or ideas for tests, just post a comment below.

@sdutry
Copy link
Contributor Author

sdutry commented Jan 19, 2017

@lukaszlenart @jogep

My initial setup for these tests did not have support for drag-and-drop features (like dragging a slider).
(arbitrary mouse movement is not supported by htmlunit-driver)

Initial setup:

  • selenium
  • htmlunit-driver

My workaround for this was to use the PhantomJSDriver (instead of the htmlunit-driver) for this specific test. (see SliderTagIT.java )

This however has some implications

  • it requires the user to have phantomjs installed in order to be able to run the tests, or install ( mvn install) the project.
  • Travis-CI has phantomjs installed by default (so this did not pose a problem)

So i was wondering the following:

  • is it a good idea to add this test to the project?
  • should there be a readme.MD added to explain the requirement?
  • should there be a seperate profile added to the pom to perform the tests only for a certain profile?
  • If this is used, should i adjust the other tests to use the PhantomJSDriver instead? (which would allow me to remove the html-unit dependency from the pom)

I would appreciate your input for this.

@jogep
Copy link
Contributor

jogep commented Jan 22, 2017

@sdutry I like the idea of seperate profile for this tests. Can this profile be chosen as default for Travis-CI?

@sdutry
Copy link
Contributor Author

sdutry commented Jan 22, 2017

@jogep
Should be easy enough to run the command with a profile.

required steps:

  • Add profile to pom.
  • Move running of tests to this profile.
  • Make sure they don't run when this profile isn't being used.

What i was wondering was the following:

  • Should i switch all tests to only run for this profile?
  • Should i switch all tests to use PhantomJSDriver?
  • Should i still allow tests that should work without additional requirement to run while not being on this specific profile?

@sdutry
Copy link
Contributor Author

sdutry commented Jan 22, 2017

Looking further into this i'll try to set it up with the Category annotation to be able to filter them.

@sdutry
Copy link
Contributor Author

sdutry commented Jan 22, 2017

@jogep @lukaszlenart
I've made a pull request ( #112 ) which splits up the tests in to tests run by default with HtmlUnitDriver and tests run only with the profile phantomjs.

I also added categories to the tests in order to distinguish which test to run when.
This should also make it easy when someone decides to add a driver from an actual browser to the tests.

  • phantomjs tests were needed in order to perform drag-and-drop with a mouse
  • phantomjs can not handle alerts

I've added the both of you as reviewers to this pull request.

In case of any of the list below, please add a comment (here or in the pull request) and i'll see what can be done:

  • in case you have questions
  • in case you have remarks
  • in case you do not agree with this setup
  • in case you have ideas for improvements

Thanks in advance.

@lukaszlenart
Copy link
Member

(sorry but I was off for few days)

The idea with a dedicated profile just for phantomjs is very good, you can use ${env.TRAVIS} to activate it when build is running on TravisCI, just a hint, the current approach also works :)

@aleksandr-m
Copy link
Contributor

@sdutry Have you seen this https://github.com/klieber/phantomjs-maven-plugin ?

@sdutry
Copy link
Contributor Author

sdutry commented Feb 22, 2017

@aleksandr-m
I am aware of the existense of the plugin.

I did not find a way to have it working independent of the environment you're on (yet).
The main issues being:

  • no admin rights environments
    • will it be able to place the required files
    • Travis-ci environment has no admin rights, but has phantomjs installed by default
  • phantomjs.binary.path
    • what if the person already has phantomjs installed on a different location
  • executing both PhantomJsDriver tests and HtmlUnitDriver tests in a single command
    • not all tests can be run with phantomjs
    • not all tests can be run with htmlunit

Should you have an example of a working setup feel free to show me.

Feel free to make a pull request with the adjusted setup.
Just be sure to also update the .travis.yml accordingly

If you want to play with it on a personal fork (and possibly branch inside the fork) first, all you need to do is enable the forked repository on travis and it will run the tests for you on each commit (pushed to github).

@sdutry
Copy link
Contributor Author

sdutry commented Jan 2, 2018

replaced open parts of the issue with #155 and #156

@sdutry sdutry closed this as completed Jan 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants