http://hg.netbeans.org/simpletests/
hg clone -r d6fb81940cd5 main simpletests hg -R simpletests pull http://hg.netbeans.org/simpletests/
Running out of memory when executing your tests? Try:
--- a/o.n.core/nbproject/project.properties Wed Jun 25 16:18:57 2008 -0400
+++ b/o.n.core/nbproject/project.properties Wed Jun 25 16:33:04 2008 -0400
@@ -50,4 +50,5 @@ test.excludes=\
org/netbeans/core/projects/data/
-
+# Otherwise ValidateLayerConsistencyTest can fail:
+test.run.args=-ea -XX:MaxPermSize=200m
This is the sample change that was needed in order to execute the web.structs module in the IDE mode in the new way:
diff -r 59a0ec8e6882 web.struts/nbproject/project.xml
--- a/web.struts/nbproject/project.xml Mon May 19 14:47:53 2008 +0200
+++ b/web.struts/nbproject/project.xml Mon May 19 14:48:13 2008 +0200
@@ -339,6 +339,7 @@ made subject to such option by the copyr
</test-dependency>
<test-dependency>
<code-name-base>org.netbeans.modules.nbjunit</code-name-base>
+ <recursive/>
<compile-dependency/>
</test-dependency>
</test-type>
diff -r 59a0ec8e6882 web.struts/test/qa-functional/src/test/EndToEndTest.java
--- a/web.struts/test/qa-functional/src/test/EndToEndTest.java Mon May 19 14:47:53 2008 +0200
+++ b/web.struts/test/qa-functional/src/test/EndToEndTest.java Mon May 19 14:48:13 2008 +0200
@@ -48,6 +48,7 @@ import java.net.URLConnection;
import java.net.URLConnection;
import java.util.Properties;
import javax.swing.JTextField;
+import junit.framework.Test;
import org.netbeans.jellytools.Bundle;
import org.netbeans.jellytools.EditorOperator;
import org.netbeans.jellytools.NewFileWizardOperator;
@@ -60,7 +61,6 @@ import org.netbeans.jemmy.Waitable;
import org.netbeans.jemmy.Waitable;
import org.netbeans.jemmy.Waiter;
import org.netbeans.jemmy.operators.JButtonOperator;
-import org.netbeans.junit.NbTestSuite;
import org.netbeans.jellytools.JellyTestCase;
import org.netbeans.jellytools.NbDialogOperator;
import org.netbeans.jellytools.NewFileNameLocationStepOperator;
@@ -79,6 +79,7 @@ import org.netbeans.jemmy.operators.JTex
import org.netbeans.jemmy.operators.JTextFieldOperator;
import org.netbeans.jemmy.operators.JTreeOperator;
import org.netbeans.jemmy.operators.Operator.DefaultStringComparator;
+import org.netbeans.junit.NbModuleSuite;
import org.netbeans.junit.ide.ProjectSupport;
/** End-to-end scenario test based on
@@ -96,27 +97,22 @@ public class EndToEndTest extends JellyT
}
/** Creates suite from particular test cases. You can define order of testcases here. */
- public static NbTestSuite suite() {
- NbTestSuite suite = new NbTestSuite();
- suite.addTest(new EndToEndTest("testSetupStrutsProject"));
- suite.addTest(new EndToEndTest("testCreateLoginPage"));
- suite.addTest(new EndToEndTest("testCreateLoginBean"));
- suite.addTest(new EndToEndTest("testCreateLoginAction"));
- suite.addTest(new EndToEndTest("testCreateSecurityManager"));
- suite.addTest(new EndToEndTest("testCreateForward"));
- suite.addTest(new EndToEndTest("testCreateShopPage"));
- suite.addTest(new EndToEndTest("testCreateLogoutPage"));
- suite.addTest(new EndToEndTest("testCreateForwardInclude"));
- suite.addTest(new EndToEndTest("testRunApplication"));
- return suite;
- }
-
- /* Method allowing test execution directly from the IDE. */
- public static void main(java.lang.String[] args) {
- // run whole suite
- junit.textui.TestRunner.run(suite());
- // run only selected test case
- //junit.textui.TestRunner.run(new EndToEndTest("test1"));
+ public static Test suite() {
+ return NbModuleSuite.create(
+ NbModuleSuite.createConfiguration(EndToEndTest.class).addTest(
+ "testSetupStrutsProject", "testCreateLoginPage", "testCreateLoginBean",
+ "testCreateLoginAction", "testCreateSecurityManager", "testCreateForward",
+ "testCreateShopPage", "testCreateLogoutPage", "testCreateForwardInclude",
+ "testRunApplication"
+ )
+ .enableModules(".*")
+ .clusters(".*")
+ );
}
/** Called before every test case. */
Quite easy, almost one to one mapping, one would say. More info is also available directly from the users, the quality engineers.
QUESTION (from Tom Wheeler): The XTestReplacementCookBook link above points to a non-public Sun server. I would be very interested in reading it -- and anything else that has to do with testing platform applications. Is there a chance you could post a copy somewhere that non-Sun people could get to it?
If you want to create config with name e.g. commit, go to $MODULENAME/nbproject/project.properties and add property which classes you want to run:
test.config.commit.includes=\
org/netbeans/test/ide/IDECommitValidationTest.class,\
org/netbeans/test/editor/MultiviewEditorReflectionTest.class
This example comes from ide.kit module. You can use also wildcards:
test.config.commit.includes=**/Validate*Test.classThis example comes from core.windows module.
These tests are executable from $MODULENAME directory with this command.
ant test-qa-functional -Dtest.config=commit
If you have multiple tests that are supposed to run in the same VM, in the specified order. Then you can either place them into one Test class and have correct order of its methods, or, if you have them in multiple classes, you can use the ordering abilities of NbModuleSuite:
public static Test suite() {
return NbModuleSuite.create(
NbModuleSuite.emptyConfiguration()
.addTest(FirstTest.class)
.addTest(SecondTest.class)
.addTest(ThirdTest.class)
);
}
This will guarantee that all testXYZ methods in the FirstTest class are executed first, and then the SecondTest, etc. You can also explicitly list the individual test method names, in case you want to control that order as well by: addTest(FirstTest.class, "testM1", "testM2");
Imagine you have one test case that contains a lot of tests, but you'd like to run them in various configurations: stable, all, really stable, etc. This is the recommended structure for your tests
public class CheckIDEWorks extends NbTestCase {
public CheckIDEWorks(String n) { super(n); }
public void testBasics() { ... }
public void testMore() { ... }
public void testRest() { ... }
}
The previous example define a regular test case with a set of methods that define behaviour of all your tests. However, it is not executed by the infrastructure by default, as its name does not end with "Test", and as such it is not recognized as test. You can do that, if you want, but suppose you want to create three different configurations for these tests. Then you can define own classes:
public class Stable {
public static Test suite() {
return NbModuleSuite.create(
NbModuleSuite.emptyConfiguration()
.addTest(CheckIDEWorks.class, "testBasics", "testMore")
);
}
}
public class ReallyStable {
public static Test suite() {
return NbModuleSuite.create(
NbModuleSuite.emptyConfiguration()
.addTest(CheckIDEWorks.class, "testBasics")
);
}
}
public class AllTest {
public static Test suite() {
return NbModuleSuite.create(
NbModuleSuite.emptyConfiguration()
.addTest(CheckIDEWorks.class) // without a list of testcases, all are executed
);
}
}
Now, you can just predefine various configs that you wish to be executed. So you can have a test config for stable, as well as commit set of tests in your nbproject/project.properties:
test.config.stable.includes=**/Stable.class test.config.commit.includes=**/ReallyStable.class
You may, but need not specify config for all tests, by default every class with name that ends with Test is included, which in our example means just AllTest. With a style like this you can create as many tests as you want, group them into execution units according to their stability and just by changing properties specify which execution units shall be executed when.
To get an auto access to servers(Tomcat, Glassfish, JBoss) you should extend J2eeTestCase instead of JellyTestCase. It provides methods
Configuration addServerTests(Configuration, String...) Configuration addServerTests(Server server, Configuration, String...)
Serveris an enum of actually supported servers. The methods are trying to find server using system properties and register it into the IDE. If there is a required server, test's are added into configuration, if there is no required server emptyTest is added so that the configuration would be runnable but no failure appeared.
If no server is required, no server is registered in IDE.
You can also use methods isRegistered(Server server), getServerNode(Server server) these are supposed to by used in test runtime.
If you need to run your test on all servers use addServerTests(...) and start test with different server settings each time.
To set server path start test using ant command ant -Dtest-qa-functional-sys-prop.tomcat.home=/instalace/tomcat test or set tomcat.home, jboss.home, glassfish.home properties in different way.
ant -Dnetbeans.dest.dir=/space/simpletests/netbeans \ -Dmodules.list=java2/org-netbeans-modules-ant-grammarfails with
BUILD FAILED /space/simpletests/build.xml:47: The following error occurred while executing this line: /space/simpletests/all-tests.xml:61: Invalid file: /space/simpletests/qa-functional/java2/org-netbeans-modules-ant-grammar
After merge, should also update TestDistribution.
Many modules have both unit and qa-functional test dirs:
ls -1d `hg loc -r tip '*/test/qa-functional/src/**Test.java' \ | perl -pi -e 's!/qa-functional/src/.*!/unit/src!g' | sort | uniq`
jemmy.log gets correctly written to test workdir. Seems that screen.png screenshots get saved correctly too (JellyTestCase.runBare). Will need some way to collect workdirs and publish them. Minimally, include e.g. */build/test/work/ in Hudson artifacts. Nicer would be to have a plugin which collects them and links to them from test results.
Binary test distribution creates complete dist for all clusters (easy to pick apart manually if desired).
test.unit.cp calculation ignores Class-Path extensions (now fixed in branch)
Cannot set bigger -mx for tests (fixed in branch)
Do not include nbjunit in test CP without explicit decl (fixed in branch, so long as you specify at least dep on junit)
openide/loaders QAFunctional tests are marked as uncompilable (seems fine in branch)
Implement qa-functional tests node (now fixed in branch)
Errors in execution of binary tests distribution should be passed to parent ant task
Wrong class path order set while running JUnit test via NB default ant scripts
Support for Emma coverage in external NBM projects
We develop several platform-based applications and do a lot of testing at work. I make the following suggestions based on our experience:
ant -Dnetbeans.dest.dir=/space/simpletests/netbeans \ -Dmodules.list=java2/org-netbeans-modules-ant-grammarfails with
BUILD FAILED /space/simpletests/build.xml:47: The following error occurred while executing this line: /space/simpletests/all-tests.xml:61: Invalid file: /space/simpletests/qa-functional/java2/org-netbeans-modules-ant-grammarJesseGlick: should be easy enough to fix.
ant -Dnetbeans.dest.dir=/space/simpletests/netbeans \ -Dmodules.list=ide9/org-netbeans-modules-utilities -Dtest.disable.fails=truetest gets stuck and ends with some o.n.jemmy.TimeoutExpiredException, while running only
ant -Dnetbeans.dest.dir=/space/simpletests/netbeans \ -Dmodules.list=ide9/org-netbeans-modules-utilitiesends with normal test error and build failure. JesseGlick: should be easy to fix with JUnitReportSubant.
...
public static Test suite() {
NbTestSuite s = new NbTestSuite("UI Responsiveness J2SE Menus suite");
s.addTest(NbModuleSuite.create(MainMenu.class, ".*", ".*"));
s.addTest(NbModuleSuite.create(MainSubMenus.class, ".*", ".*"));
...
IZ bug: 134525
These are my first impressions after nominally getting simpletests working for a platform app.
| X.diff | ![]() |
47756 bytes |