1 19 20 25 26 package org.netbeans.test.junit.testcreation; 27 28 import org.netbeans.jellytools.Bundle; 29 import org.netbeans.jellytools.EditorOperator; 30 import org.netbeans.jellytools.NbDialogOperator; 31 import org.netbeans.jellytools.NewFileWizardOperator; 32 import org.netbeans.jellytools.nodes.Node; 33 import org.netbeans.jemmy.operators.JButtonOperator; 34 import org.netbeans.jemmy.operators.JCheckBoxOperator; 35 import org.netbeans.jemmy.operators.JPopupMenuOperator; 36 import org.netbeans.jemmy.operators.JTextFieldOperator; 37 import org.netbeans.junit.NbTestSuite; 38 import org.netbeans.test.junit.testcase.JunitTestCase; 39 import org.netbeans.test.junit.utils.Utilities; 40 41 45 public class CreateTestTest extends JunitTestCase { 46 47 48 private static final String TEST_PACKAGE_PATH = 49 "org.netbeans.test.junit.testcreation"; 50 51 52 private static final String TEST_PACKAGE_NAME = TEST_PACKAGE_PATH+".test"; 53 54 57 public CreateTestTest(String testName) { 58 super(testName); 59 } 60 61 65 public static NbTestSuite suite() { 66 NbTestSuite suite = new NbTestSuite(CreateTestTest.class); 67 return suite; 68 } 69 70 74 public void testCreateTestByPopup() { 75 Node n = Utilities.openFile(Utilities.SRC_PACKAGES_PATH + 77 "|" + TEST_PACKAGE_NAME+ "|" + Utilities.TEST_CLASS_NAME); 78 79 Utilities.pushCreateTestsPopup(n); 80 81 NbDialogOperator ndo = new NbDialogOperator(CREATE_TESTS_DIALOG); 82 ndo.btOK().push(); Utilities.takeANap(Utilities.ACTION_TIMEOUT); 84 85 ref(filter.filter(new EditorOperator(Utilities.TEST_CLASS_NAME + "Test.java").getText())); 86 compareReferenceFiles(); 87 } 88 89 93 public void testCreateTestByPopup2() { 94 Utilities.deleteNode(Utilities.TEST_PACKAGES_PATH + 95 "|" + TEST_PACKAGE_NAME); 96 97 Node n = Utilities.openFile(Utilities.SRC_PACKAGES_PATH + 98 "|" + TEST_PACKAGE_NAME+ "|" + Utilities.TEST_CLASS_NAME); 99 100 Utilities.pushCreateTestsPopup(n); 101 102 NbDialogOperator ndo = new NbDialogOperator(CREATE_TESTS_DIALOG); 103 JCheckBoxOperator jbo = new JCheckBoxOperator(ndo, 0); jbo.clickMouse(); 105 ndo.btOK().push(); 106 Utilities.takeANap(Utilities.ACTION_TIMEOUT); 107 108 ref(filter.filter(new EditorOperator(Utilities.TEST_CLASS_NAME + 109 "Test.java").getText())); 110 compareReferenceFiles(); 111 } 112 113 117 public void testCreateTestByPopup3() { 118 Utilities.deleteNode(Utilities.TEST_PACKAGES_PATH + 120 "|" + TEST_PACKAGE_NAME); 121 122 Node n = Utilities.openFile(Utilities.SRC_PACKAGES_PATH + 123 "|" + TEST_PACKAGE_NAME+ "|" + Utilities.TEST_CLASS_NAME); 124 125 Utilities.pushCreateTestsPopup(n); 126 127 NbDialogOperator ndo = new NbDialogOperator(CREATE_TESTS_DIALOG); 128 JCheckBoxOperator jbo = new JCheckBoxOperator(ndo, 1); jbo.clickMouse(); 130 ndo.btOK().push(); 131 Utilities.takeANap(Utilities.ACTION_TIMEOUT); 132 133 ref(filter.filter(new EditorOperator(Utilities.TEST_CLASS_NAME + "Test.java").getText())); 134 compareReferenceFiles(); 135 } 136 137 142 public void testCreateTestByPopup4() { 143 Utilities.deleteNode(Utilities.TEST_PACKAGES_PATH + 145 "|" + TEST_PACKAGE_NAME); 146 147 Node n = Utilities.openFile(Utilities.SRC_PACKAGES_PATH + 148 "|" + TEST_PACKAGE_NAME + "|" + Utilities.TEST_CLASS_NAME); 149 Utilities.pushCreateTestsPopup(n); 150 151 NbDialogOperator ndo = new NbDialogOperator(CREATE_TESTS_DIALOG); 152 JCheckBoxOperator jbo = new JCheckBoxOperator(ndo, 2); jbo.clickMouse(); 154 Utilities.takeANap(Utilities.ACTION_TIMEOUT); 155 assertFalse(ndo.btOK().isEnabled()); ndo.btCancel().push(); } 158 159 162 public void testCreateWOsetUp() { 163 Node n = Utilities.openFile(Utilities.SRC_PACKAGES_PATH + 164 "|" + TEST_PACKAGE_NAME + "|" + Utilities.TEST_CLASS_NAME); 165 Utilities.pushCreateTestsPopup(n); 166 167 NbDialogOperator ndo = new NbDialogOperator(CREATE_TESTS_DIALOG); 168 Utilities.checkAllCheckboxes(ndo); 169 JCheckBoxOperator jbo = new JCheckBoxOperator(ndo, 3); jbo.clickMouse(); 171 Utilities.takeANap(Utilities.ACTION_TIMEOUT); 172 ndo.btOK().push(); 173 174 ref(filter.filter(new EditorOperator(Utilities.TEST_CLASS_NAME + "Test.java").getText())); 175 compareReferenceFiles(); 176 } 177 178 181 public void testCreateWOtearDown() { 182 Utilities.takeANap(Utilities.ACTION_TIMEOUT); 184 Utilities.deleteNode(Utilities.TEST_PACKAGES_PATH + 185 "|" + TEST_PACKAGE_NAME); 186 Utilities.takeANap(Utilities.ACTION_TIMEOUT); 187 188 Node n = Utilities.openFile(Utilities.SRC_PACKAGES_PATH + 189 "|" + TEST_PACKAGE_NAME + "|" + Utilities.TEST_CLASS_NAME); 190 Utilities.pushCreateTestsPopup(n); 191 192 NbDialogOperator ndo = new NbDialogOperator(CREATE_TESTS_DIALOG); 193 Utilities.checkAllCheckboxes(ndo); 194 JCheckBoxOperator jbo = new JCheckBoxOperator(ndo, 4); jbo.clickMouse(); 196 Utilities.takeANap(Utilities.ACTION_TIMEOUT); 197 ndo.btOK().push(); 198 199 ref(filter.filter(new EditorOperator(Utilities.TEST_CLASS_NAME + "Test.java").getText())); 200 compareReferenceFiles(); 201 } 202 203 206 public void testCreateWODefMethodBodies() { 207 Utilities.takeANap(Utilities.ACTION_TIMEOUT); 209 Utilities.deleteNode(Utilities.TEST_PACKAGES_PATH + 210 "|" + TEST_PACKAGE_NAME); 211 Utilities.takeANap(Utilities.ACTION_TIMEOUT); 212 213 Node n = Utilities.openFile(Utilities.SRC_PACKAGES_PATH + 214 "|" + TEST_PACKAGE_NAME + "|" + Utilities.TEST_CLASS_NAME); 215 Utilities.pushCreateTestsPopup(n); 216 217 NbDialogOperator ndo = new NbDialogOperator(CREATE_TESTS_DIALOG); 218 Utilities.checkAllCheckboxes(ndo); 219 JCheckBoxOperator jbo = new JCheckBoxOperator(ndo, 5); jbo.clickMouse(); 221 Utilities.takeANap(Utilities.ACTION_TIMEOUT); 222 ndo.btOK().push(); 223 224 ref(filter.filter(new EditorOperator(Utilities.TEST_CLASS_NAME + "Test.java").getText())); 225 compareReferenceFiles(); 226 } 227 228 231 public void testCreateWOJavadoc() { 232 Utilities.takeANap(Utilities.ACTION_TIMEOUT); 234 Utilities.deleteNode(Utilities.TEST_PACKAGES_PATH + 235 "|" + TEST_PACKAGE_NAME); 236 Utilities.takeANap(Utilities.ACTION_TIMEOUT); 237 238 Node n = Utilities.openFile(Utilities.SRC_PACKAGES_PATH + 239 "|" + TEST_PACKAGE_NAME + "|" + Utilities.TEST_CLASS_NAME); 240 Utilities.pushCreateTestsPopup(n); 241 242 NbDialogOperator ndo = new NbDialogOperator(CREATE_TESTS_DIALOG); 243 Utilities.checkAllCheckboxes(ndo); 244 JCheckBoxOperator jbo = new JCheckBoxOperator(ndo, 6); 246 jbo.clickMouse(); 247 Utilities.takeANap(Utilities.ACTION_TIMEOUT); 248 ndo.btOK().push(); 249 250 ref(filter.filter(new EditorOperator(Utilities.TEST_CLASS_NAME + "Test.java").getText())); 251 compareReferenceFiles(); 252 } 253 254 257 public void testCreateWOHints() { 258 Utilities.takeANap(Utilities.ACTION_TIMEOUT); 260 Utilities.deleteNode(Utilities.TEST_PACKAGES_PATH + 261 "|" + TEST_PACKAGE_NAME); 262 Utilities.takeANap(Utilities.ACTION_TIMEOUT); 263 264 Node n = Utilities.openFile(Utilities.SRC_PACKAGES_PATH + 265 "|" + TEST_PACKAGE_NAME + "|" + Utilities.TEST_CLASS_NAME); 266 Utilities.pushCreateTestsPopup(n); 267 268 NbDialogOperator ndo = new NbDialogOperator(CREATE_TESTS_DIALOG); 269 Utilities.checkAllCheckboxes(ndo); 270 JCheckBoxOperator jbo = new JCheckBoxOperator(ndo, 7); 272 jbo.clickMouse(); 273 Utilities.takeANap(Utilities.ACTION_TIMEOUT); 274 ndo.btOK().push(); 275 276 ref(filter.filter(new EditorOperator(Utilities.TEST_CLASS_NAME + "Test.java").getText())); 277 compareReferenceFiles(); 278 } 279 280 283 public void testCreateTestByWizard() { 284 Utilities.takeANap(Utilities.ACTION_TIMEOUT); 286 Utilities.deleteNode(Utilities.TEST_PACKAGES_PATH + 287 "|" + TEST_PACKAGE_NAME); 288 Utilities.takeANap(Utilities.ACTION_TIMEOUT); 289 290 NewFileWizardOperator op = NewFileWizardOperator.invoke(); 291 op.selectCategory(Bundle.getString(Utilities.JUNIT_BUNDLE, 292 "Templates/JUnit")); 293 op.selectFileType(Bundle.getString(Utilities.JUNIT_BUNDLE, 294 "Templates/JUnit/SimpleJUnitTest.java")); 295 op.next(); 296 new JTextFieldOperator(op,0). 297 setText("org.netbeans.test.junit.testcreation.test.TestClass"); 298 op.finish(); 299 Utilities.takeANap(Utilities.ACTION_TIMEOUT); 300 301 ref(filter.filter(new EditorOperator(Utilities.TEST_CLASS_NAME + "Test.java").getText())); 302 compareReferenceFiles(); 303 304 } 308 309 } 310 | Popular Tags |