-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Migrate 'Unit Test' to jenkins.io developer docs #3385
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This pull request is mixing multiple changes that are unrelated to 'Unit test'. It needs to be reworked to remove the 'agent to master control' changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Several sections in this new page already exist in the index.adoc file. I've marked them for removal here.
Other items need correction (like HUDSON_
-> JENKINS_
).
My apologies for the long delay and for the inadequate triage of this page before including it in the candidate pages. The migration of this page is difficult due to the age of the page and the evolving nature of Jenkins development.
@MarkEWaite @oleg-nenashev @v1v @markyjackson-taulia I have been able to go through and reviewed the changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we also can split that file so that the UI testing part can be separated into another page (where we can make clear that this approach is not recommended or at least will create problems while we are modernizing Jenkins UI).
@@ -0,0 +1,435 @@ | |||
--- | |||
layout: section | |||
title: Unit test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name unit test is misleading, this document is actually describing integration testing within Jenkins. Unit tests are tests of source code units in isolation (without a running Jenkins instance). We should not change semantics of well known definitions (this was wrong in the wiki already but when we migrate it to the new home we should consider using the correct names).
title: Unit test | ||
--- | ||
|
||
[[UnitTest-Overview]] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[[UnitTest-Overview]] | |
[[IntegrationTest-Overview]] |
. Starts an embedded servlet container so that the test code can | ||
exercise user interaction through HTTP and assert based on the outcome. | ||
. http://htmlunit.sourceforge.net/[HtmlUnit] with a bit of enhancements | ||
allows you to productively test HTTP/UI interaction. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently a lot of plugins use this approach but I cannot recommend it anymore. While we are using more and more rich and modern UI libraries that are not compatible with HTMLUnit we are creating obstacles by those tests that slow down progress (see jenkinsci/junit-plugin#272). UI testing should be solely done using ATH plugin tests.
If you are using the Plugin Parent POM 2.3 or later the version of the | ||
Jenkins Test Harness (which starting in version 2.0 is an artifact | ||
independent from Jenkins Core) to be used for the tests can be | ||
configured using the `+jenkins-test-harness.version+`. For 1.x versions | ||
of the Plugin POM the version used is the same of the parent POM which | ||
is equal to the Jenkins baseline version. The recommended version of | ||
Jenkins Test Harness is 2.1 or above unless your plugin depends on | ||
Jenkins < 1.580. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this section is obsolete in 2022.
== Example | ||
|
||
The following code shows a very simple test case. Your test will use | ||
http://javadoc.jenkins-ci.org/byShortName/JenkinsRule[JenkinsRule] to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This URL does not exist
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe also check for other HTTP URLs in this document.
project.getBuildersList().add(new Shell("echo hello")); | ||
FreeStyleBuild build = project.scheduleBuild2(0).get(); | ||
System.out.println(build.getDisplayName() + " completed"); | ||
// TODO: change this to use HtmlUnit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Delete line
// TODO: change this to use HtmlUnit |
|
||
Your IDE will most likely have the ability to select a single JUnit test | ||
and execute it in the debugger. Otherwise you can run | ||
`+mvn -Dmaven.surefire.debug -Dtest=hudson.SomeTest test+` to accomplish |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
`+mvn -Dmaven.surefire.debug -Dtest=hudson.SomeTest test+` to accomplish | |
`+mvn -Dmaven.surefire.debug -Dtest=SomeTest test+` to accomplish |
---- | ||
|
||
[[UnitTest-HTMLscraping]] | ||
=== HTML scraping |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above
As this pull request has not had any updates from the submitter since June 2020, and has been marked |
Description
Fix #3320