TS 73 GroovyGrails Sanity

Sanity Test Specification for NetBeans Groovy and Grails Support Functionality

Author: Jose Galaviz, based on GroovyGrailsTests
Last update: November 29, 2012
NetBeans version: NetBeans 7.3
Introduction: Test cases for sanity testing of NetBeans Groovy and Grails Support functionality.

Contents

Prerequisites

  • Install Groovy as defined in Groovy - Installing Groovy.
  • Download and decompress the Groovy documentation from Groovy - Download. The documentation must be registered at ToolsOptions, select Miscellaneous, and click on the Groovy tab (Tip: the path is "<groovydocs>/html/"). If you are OS X user, select - NetBeans → 'Preferences ..., select Miscellaneous.
  • Install Grails as defined in Grails - Getting Started.
  • Install the to-be-tested version of Netbeans with a clean userdir.

Tests

Test suite: Create grails project

Purpose: Test verifies that the default project will run and create basic files correctly
Expected time: 5 minutes
Setup: Start IDE with clear userdir

  1. Create a new project
    1. From the menu, select FileNew Project
    2. On Categories, select Groovy and in Projects select Grails Application, then click on Next (this may take a while if is activating the Groovy features)
    3. Leave the default project name
    4. Click on Finish (it will take a while also)
    5. Right click on the project node and then Run
  2. Debug the project
    1. Right click on the project node and then Debug
  3. Test the project
    1. Right click on the project node and then Test
    • EXPECTED RESULT: The output window must show the message " Tests PASSED - view reports in <path>".

Test suite: Groovy on Java Project

Purpose: Test verifies that the integration of Groovy on a JDK project will work correctly
Expected time: 15 minutes

  1. Create a new ant-based JDK project
    1. From the menu, select FileNew Project
    2. On Categories, select Java and in Projects select Java Application, then click on Next
    3. Leave the default project name and settings
    4. Click on Finish
    5. Right-click on the created package and select NewOther
    6. On the New File dialog window, select Groovy in Categories and Groovy Class as File type. Click on Next
    7. Leave the default name and settings and click on Finish
    8. Within the newly created class, we must create a new method that should look as follows:
class NewGroovyClass {
    
    def runIt() {
        println 'groovyshly'
    }
    
}
    1. We now go to the default main class, and we create an instance of the Groovy class and call the method from the Java main class. The Java class must be as follows:
public static void main(String[] args) {
    NewGroovyClass ngc = new NewGroovyClass();
    ngc.runIt();
}
    1. Press F6
    • EXPECTED RESULT: The output window shows the text "Groovyshly".
    1. Navigate to the groovy class
    2. Place the cursor anywhere in the word println
    3. Press Ctrl+Space (in OS X press - "Ctrl - space")
    • EXPECTED RESULT: A list of matching methods pops-up and valid documentation entry is shown for every element that gets highlighted
  1. Create a new maven-based JDK project
    1. From the menu, select FileNew Project
    2. On Categories, select Maven and in Projects select Java Application, then click on Next
    3. Leave the default project name and settings
    4. Click on Finish
    5. Right-click on the created package and select NewOther
    6. On the New File dialog window, select Groovy in Categories and Groovy Class as File type. Click on Next
    7. Leave the default name and settings and click on Finish
    8. Within the newly created class, we must create a new method that should look as follows:
class NewGroovyClass {
    
    def runIt() {
        println 'groovyshly'
    }
    
}
    1. We now go to the default main class, and we create an instance of the Groovy class and call the method from the Java main class. The Java class must be as follows:
public static void main(String[] args) {
    NewGroovyClass ngc = new NewGroovyClass();
    ngc.runIt();
}
    1. Press F6
    • EXPECTED RESULT: The output window shows the text "Groovyshly".
  1. Create a new Web project
    1. From the menu, select FileNew Project
    2. On Categories, select Java Web and in Projects select Web Application, then click on Next
    3. Leave the default project name and settings, click on Next
    4. Leave the default server and Java EE version, click on Finish
    5. Right-click on the project node and select NewJava Package
    6. Leave the default package name and click on Finish
    7. Right-click on the created package and select NewOther
    8. On the New File dialog window, select Groovy in Categories and Groovy Class as File type. Click on Next
    9. Leave the default name and settings and click on Finish
    10. Within the newly created class, we must create a new method that should look as follows:
class NewGroovyClass {
    
    def String getIt() {
        return 'groovyshly'
    }
    
}
    1. We now go to the Web Pages node, and open the index.jsp file in the editor. We must replace our file with the following:
<%@page import="newpackage.*" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Groovy / JSP Page</title>
    </head>
    <body>
        <h1>Getting it <%= new NewGroovyClass().getIt()%>!</h1>
    </body>
</html>
    1. Press F6
    • EXPECTED RESULT: A new browser window is open and shows the text "Getting it groovyshly!".
  1. Create a new Enterprise Application project
    1. From the menu, select FileNew Project
    2. On Categories, select Java EE and in Projects select Enterprise Application, then click on Next
    3. Leave the default project name and settings, click on Next
    4. Leave the default server and Java EE version, click on Finish
    5. Three project nodes are created. Right-click on the -war node and select NewJava Package
    6. Leave the default package name and click on Finish
    7. Right-click on the created package and select NewOther
    8. On the New File dialog window, select Groovy in Categories and Groovy Class as File type. Click on Next
    9. Leave the default name and settings and click on Finish
    10. Within the newly created class, we must create a new method that should look as follows:
class NewGroovyClass {
    
    def String getIt() {
        return 'groovyshly'
    }
    
}
    1. Within the same project node, we now go to the Web Pages node, and open the index.jsp file in the editor. We must replace our file with the following:
<%@page import="newpackage.*" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Groovy / JSP Page</title>
    </head>
    <body>
        <h1>Getting it <%= new NewGroovyClass().getIt()%>!</h1>
    </body>
</html>
    1. Click on the main project node (the one without a suffix)
    2. Press F6
    • EXPECTED RESULT: A new browser window is open and shows the text "Getting it groovyshly!".

Test suite: Unit testing with Groovy on Java Projects

Purpose: Test verifies that the Unit testing created using Groovy will work correctly
Expected time: 15 minutes

  1. Test an ant-based JDK project
    1. Right-click on the ant-based JDK project created on the previous suite and select NewOther
    2. On the New File dialog window, select Groovy in Categories and Groovy JUnit Test as File type. Click on Next
    3. Leave the default name, write anypackage on the package field and click on Finish
    4. When the JUnit version window pops-up, select JUnit 4.x and then click on Select
    5. Within the newly created class, we must un-comment the method at the bottom of the class and add a text and a default assertion:
@Test
public void hello() {
    println 'hello groovy'
    assertTrue(true)
}
    1. Press Alt+F6
    • EXPECTED RESULT: The test output window is in green with the label "The test passed" and a printed text "hello groovy".
  1. Test a maven-based JDK project
    1. Right-click on the maven-based JDK project created on the previous suite and select NewOther
    2. On the New File dialog window, select Groovy in Categories and Groovy JUnit Test as File type. Click on Next
    3. Leave the default name, write anypackage on the package field and click on Finish
    4. Within the newly created class, we must un-comment the method at the bottom of the class and add a text and a default assertion:
public void testHello() {
    println 'hello groovy'
    assertTrue(true)
}
    1. Press Alt+F6
    • EXPECTED RESULT: The test output window is in green with the label "The test passed" and a printed text "hello groovy".
  1. Test a Web project
    1. Right-click on the Web project created on the previous suite and select NewOther
    2. On the New File dialog window, select Groovy in Categories and Groovy JUnit Test as File type. Click on Next
    3. Leave the default name, write anypackage on the package field and click on Finish
    4. When the JUnit version window pops-up, select JUnit 4.x and then click on Select
    5. Within the newly created class, we must un-comment the method at the bottom of the class and add a text and a default assertion:
@Test
public void hello() {
    println 'hello groovy'
    assertTrue(true)
}
    1. Press Alt+F6
    • EXPECTED RESULT: The test output window is in green with the label "The test passed" and a printed text "hello groovy".
  1. Test an Enterprise project
    1. Right-click on the -war project node of the Enterprise Application created on the previous suite and select NewOther
    2. On the New File dialog window, select Groovy in Categories and Groovy JUnit Test as File type. Click on Next
    3. Leave the default name, write anypackage on the package field and click on Finish
    4. When the JUnit version window pops-up, select JUnit 4.x and then click on Select
    5. Within the newly created class, we must un-comment the method at the bottom of the class and add a text and a default assertion:
@Test
public void hello() {
    println 'hello groovy'
    assertTrue(true)
}
    1. Press Alt+F6
    • EXPECTED RESULT: The test output window is in green with the label "The test passed" and a printed text "hello groovy".

Test suite: Grails plugin

Purpose: Test verifies the Grails plugin manager
Expected time: 5 minutes

  1. Create a new project
    1. From the menu, select FileNew Project
    2. On Categories, select Groovy and in Projects select Grails Application, then click on Next
    3. Leave the default project name
    4. Click on Finish (it will take a while also)
  2. Install a plugin
    1. Right click on the project node and then Grails plugins...
    2. Go to the tab New Plugins and wait for the list to load
    3. Select any of the plugins and then click on the button Install
    4. Click on Close
    5. Go to the Services Window, find the Jetty Server, expand the node and stop the application with the context menu
    6. Go back to the Project window
    7. Right click on the project node and then 'Run
    • EXPECTED RESULT: When the initial page is shown, the selected plugin must be shown on the installed plugins list.
  3. Uninstall a plugin
    1. Right click on the project node and then Grails plugins...
    2. Stay on the Installed tab
    3. Select any of the plugins and then click on the button Uninstall
    4. Click on Close
    5. Go to the Services Window, find the Jetty Server, expand the node and stop the application with the context menu
    6. Go back to the Project window
    7. Right click on the project node and then 'Run
    • EXPECTED RESULT: When the initial page is shown, the deleted plugin must no longer be shown on the installed plugins list.

Test suite: Demo projects

Purpose: Test verifies the demo projects work correctly
Expected time: 5 minutes

  1. Groovy-Java Demo
    1. From the menu, select FileNew Project
    2. On Categories, select Samples / Groovy and in Projects select Groovy-Java Demo, then click on Next
    3. Leave the default project name and settings
    4. Click on Finish
    5. Press F6
    • EXPECTED RESULT: The project compiles and a new Java Frame is shown
  2. NB Project Generators
    1. From the menu, select FileNB Project Generators
    2. On Categories, select Samples / Groovy and in Projects select NB Project Generators, then click on Next
    3. Leave the default project name and settings
    4. Click on Finish
    5. Press F6
    6. Select any of the main classes that are shown
    7. Watch the output window for the path where a new project is created (it's the output of the project)
    8. From the menu, select FileOpen Project, and in the file locator window go to the path shown in the output window and click Open
    9. Run the created project
    • EXPECTED RESULT: A new Netbeans window is shown
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