TS 73 Groovy

Groovy support Test Specification for NetBeans 7.3

Author: Vladimir Riha
Last update: 19th August 2013

Mac OS specific details: To find Options on MacOS, go to Netbeans menu -> Preferences


Test suite: JUnit support

  • following cases expect you to have Java Application project
  1. Create JUnit test
    1. Invoke New File dialog
    2. Select Groovy and Groovy JUnit Test to Test Packages
    3. NetBeans asks for which JUnit version the test should be generated
    4. Finish with default values
    • EXPECTED RESULT: Groovy JUnit test file is created
  2. Change JUnit settings
    1. Go to project properties | Libraries | Compile Tests
    2. Remove the JUnit item
    3. Repeat steps from previous case
    • EXPECTED RESULT: NetBeans will again ask for JUnit template
  1. Running JUnit test
    1. import org.junit.Test
      import static org.junit.Assert.assertEquals
      class DummyTest {
          void foo() {
              assertEquals 4, 2+2
          void bar() {
              assertEquals 3, 2+2
          void bar2() {
              assertEquals 3, 2+2
    2. Use the code above in some Groovy JUnit test file
    3. Run the file
    • EXPECTED RESULT: Test results and output are displayed. Only methods bar and foo were run. Fix the 2nd method and run tests again to see correct results

Test suite: Editor

  1. Mark occurrences
    1. Create sample Groovy project "NB Project Generators"
    2. Open NetBeansPlatform.groovy and click on "folder" variable
    • EXPECTED RESULT: All occurrences of this variable are highlighted (check also line 8 and lines 113 - 121)
  2. Find usages
    1. Righ click on "name" variable in NetBeansPlatform.groovy
    2. Select Find Usages
    • EXPECTED RESULT: All usages of this variable in both groovy files are found)
  3. Refactoring
    1. Righ click on "name" variable in NetBeansPlatform.groovy
    2. Select Refactor|Rename and choose some new name
    3. Click on Preview
    4. All occurrences are displayed
    5. Press Do Refactoring
    • EXPECTED RESULT: Variable was renamed, try to repeat Find Usages for "name" and make sure nothing is found. Repeat the same with folder variable but try to refactor only usages in one file )
  4. Refactoring II
    1. class Foo {
        void bar() {
           println "foobar"
    2. Create a new Groovy class called Foo and paste the snippet above
    3. Create a new Groovy script file and paste following code into it:
    4. c = new Foo() 
    5. Righ click on "Foo" class
    6. Select Refactor|Rename and choose some new name
    7. Click on Preview
    8. All occurrences are displayed
    9. Press Do Refactoring
    • EXPECTED RESULT: Class and its usages were renamed. Repeat the same with bar method

Test suite: General

  1. Context menu
    1. Invoke right click menu on some groovy file
    • EXPECTED RESULT: Context menu contains items like Run File, Debug File, Test File and Debug Test File etc.
  2. Groovy in Java Web project
    1. Create a nw Java Web project
    2. Try to create groovy file in it
    • EXPECTED RESULT: All works as in JavaSE project type
Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo