-
-
Notifications
You must be signed in to change notification settings - Fork 971
Profile tests gradle 14700 #15351
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
Draft
Ajay9704
wants to merge
9
commits into
apache:7.0.x
Choose a base branch
from
Ajay9704:profile-tests-gradle-14700
base: 7.0.x
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,642
−1
Draft
Profile tests gradle 14700 #15351
Changes from 3 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
38af3fc
Merge pull request #1 from Ajay9704/update-date-formats-docs
Ajay9704 2e3b189
Merge branch 'apache:7.0.x' into 7.0.x
Ajay9704 86725ba
(fixes #14700)
Ajay9704 453469b
Update profile tests to use containerized browsers and remove Travis CI
Ajay9704 e9c1a9e
Add grails-profiles-tests to settings.gradle
Ajay9704 2a07501
Configure tests manually to avoid circular dependencies
Ajay9704 f122617
Use local project references for dependencies
Ajay9704 3f546a5
Remove platform dependency to fix resolution issues
Ajay9704 1131928
addressed feedback
Ajay9704 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| .gradle | ||
| .idea | ||
| build | ||
| *.iml | ||
| .DS_Store | ||
| demo | ||
| .project | ||
| .settings |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| jdk: | ||
| - oraclejdk8 | ||
| addons: | ||
| chrome: stable | ||
| firefox: latest | ||
| install: ./profiles-install.sh | ||
| script: | ||
| - ./vue.sh | ||
| - ./react.sh | ||
| - ./web.sh | ||
| - ./rest-api.sh | ||
| # - ./profile.sh | ||
| # - ./rest-api-plugin.sh | ||
| # - ./web-plugin.sh | ||
| # - ./web-jboss7.sh | ||
| # - ./plugin.sh | ||
| before_cache: | ||
| - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock | ||
| - rm -fr $HOME/.gradle/caches/*/plugin-resolution/ | ||
| cache: | ||
| directories: | ||
| - $HOME/.gradle/caches/ | ||
| - $HOME/.gradle/wrapper/ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,131 @@ | ||
| # Grails Profiles Tests | ||
|
|
||
| <!-- | ||
| Licensed to the Apache Software Foundation (ASF) under one | ||
| or more contributor license agreements. See the NOTICE file | ||
| distributed with this work for additional information | ||
| regarding copyright ownership. The ASF licenses this file | ||
| to you under the Apache License, Version 2.0 (the | ||
| "License"); you may not use this file except in compliance | ||
| with the License. You may obtain a copy of the License at | ||
|
|
||
| https://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, | ||
| software distributed under the License is distributed on an | ||
| "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| KIND, either express or implied. See the License for the | ||
| specific language governing permissions and limitations | ||
| under the License. | ||
| --> | ||
|
|
||
| This module contains comprehensive tests for Grails profiles functionality, replacing the old shell script-based tests that were removed in commit 9b8fa17d40. | ||
|
|
||
| ## Purpose | ||
|
|
||
| These tests verify that Grails profiles work correctly by: | ||
| - Testing application generation with different profiles (web, plugin, rest-api, etc.) | ||
| - Verifying profile-specific commands and features | ||
| - Ensuring generated applications can be built and run successfully | ||
| - Performing functional testing of generated applications | ||
|
|
||
| ## Test Structure | ||
|
|
||
| The tests are organized into several categories: | ||
|
|
||
| ### Unit/Integration Tests | ||
| - `WebProfileTests.groovy` - Tests for the web profile | ||
| - `PluginProfileTests.groovy` - Tests for the plugin profile | ||
| - `RestApiProfileTests.groovy` - Tests for the REST API profile (to be implemented) | ||
|
|
||
| ### Functional Tests | ||
| - `FunctionalProfileTests.groovy` - End-to-end testing of generated applications using Geb/Selenium | ||
|
|
||
| ## Running the Tests | ||
|
|
||
| ### Run all profile tests: | ||
| ```bash | ||
| ./gradlew profileTest | ||
| ``` | ||
|
|
||
| ### Run functional tests specifically: | ||
| ```bash | ||
| ./gradlew functionalProfileTest | ||
| ``` | ||
|
|
||
| ### Run with specific browser: | ||
| ```bash | ||
| ./gradlew profileTest -Dgeb.env=chrome | ||
| ./gradlew profileTest -Dgeb.env=firefox | ||
| ``` | ||
|
|
||
| ### Run in headless mode (CI friendly): | ||
| ```bash | ||
| ./gradlew profileTest -Dgeb.env=chromeHeadless | ||
| ``` | ||
|
|
||
| ## Test Coverage | ||
|
|
||
| The tests cover: | ||
|
|
||
| ### Application Generation | ||
| - Creating applications with different profiles | ||
| - Verifying correct directory structure | ||
| - Checking build files are generated properly | ||
|
|
||
| ### Profile Commands | ||
| - `create-domain-class` - Domain class creation | ||
| - `create-controller` - Controller creation | ||
| - `create-service` - Service creation | ||
| - `create-taglib` - Tag library creation | ||
| - `create-unit-test` - Unit test creation | ||
|
|
||
| ### Build Verification | ||
| - Gradle compilation | ||
| - Application packaging | ||
| - Plugin JAR creation | ||
|
|
||
| ### Functional Testing | ||
| - Application startup | ||
| - Web page accessibility | ||
| - Controller functionality | ||
| - Basic UI interactions | ||
|
|
||
| ## Dependencies | ||
|
|
||
| The tests depend on: | ||
| - Grails Forge for application generation | ||
| - Geb and Selenium for functional testing | ||
| - Spock testing framework | ||
| - Chrome/Firefox drivers for browser automation | ||
|
|
||
| ## Configuration | ||
|
|
||
| The `GebConfig.groovy` file configures different browser environments: | ||
| - Chrome Headless (default for CI) | ||
| - Chrome with GUI (for debugging) | ||
| - Firefox Headless | ||
| - Firefox with GUI | ||
|
|
||
| ## Future Enhancements | ||
|
|
||
| Planned additions: | ||
| - REST API profile tests | ||
| - Web Plugin profile tests | ||
| - More comprehensive functional test scenarios | ||
| - Performance testing of profile operations | ||
| - Cross-version compatibility testing | ||
|
|
||
| ## Migration from Old Tests | ||
|
|
||
| This replaces the shell script-based testing approach that was: | ||
| - Platform-dependent (Unix/Linux only) | ||
| - Hard to maintain and debug | ||
| - Not integrated with Gradle build system | ||
| - Difficult to run in CI environments | ||
|
|
||
| The new Gradle-based approach provides: | ||
| - Cross-platform compatibility | ||
| - Better integration with existing test infrastructure | ||
| - Easier maintenance and extension | ||
| - Seamless CI/CD integration |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,122 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * https://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
|
|
||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * https://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
|
|
||
| plugins { | ||
| id 'groovy' | ||
| id 'java-library' | ||
| id 'org.apache.grails.buildsrc.properties' | ||
| id 'org.apache.grails.buildsrc.compile' | ||
| id 'org.apache.grails.gradle.grails-code-style' | ||
| } | ||
|
|
||
| version = projectVersion | ||
| group = 'org.apache.grails.testing' | ||
|
|
||
| dependencies { | ||
| implementation platform(project(':grails-bom')) | ||
|
|
||
| // Core dependencies for profile testing | ||
| implementation project(':grails-core') | ||
| implementation project(':grails-bootstrap') | ||
|
|
||
| // Testing dependencies | ||
| testImplementation project(':grails-test-core') | ||
| testImplementation project(':grails-testing-support-core') | ||
|
|
||
| // Spock testing framework | ||
| testImplementation 'org.spockframework:spock-core' | ||
| testRuntimeOnly 'net.bytebuddy:byte-buddy' | ||
| testImplementation 'org.objenesis:objenesis' | ||
|
|
||
| // JUnit platform | ||
| testRuntimeOnly 'org.junit.platform:junit-platform-launcher' | ||
|
|
||
| // Logging for tests | ||
| testImplementation 'org.slf4j:slf4j-simple' | ||
| } | ||
|
|
||
| // Configure test tasks | ||
| test { | ||
| useJUnitPlatform() | ||
|
|
||
| // Enable Geb environment configuration | ||
| systemProperty 'geb.env', System.getProperty('geb.env', 'chrome') | ||
| systemProperty 'webdriver.chrome.driver', System.getProperty('webdriver.chrome.driver', '') | ||
| systemProperty 'webdriver.gecko.driver', System.getProperty('webdriver.gecko.driver', '') | ||
|
|
||
| // Test reporting configuration | ||
| testLogging { | ||
| events "passed", "skipped", "failed" | ||
| exceptionFormat "full" | ||
| showStandardStreams = true | ||
| } | ||
|
|
||
| // Fork settings for isolation | ||
| maxParallelForks = 1 | ||
| forkEvery = 5 | ||
|
|
||
| // Include only profile test classes | ||
| include '**/*Profile*Test*' | ||
| include '**/*Profile*Spec*' | ||
| } | ||
|
|
||
| // Custom task to run profile tests with specific configurations | ||
| tasks.register('profileTest', Test) { | ||
| useJUnitPlatform() | ||
| systemProperty 'geb.env', 'chromeHeadless' | ||
| include '**/*Profile*Test*' | ||
| include '**/*Profile*Spec*' | ||
|
|
||
| testLogging { | ||
| events "passed", "skipped", "failed" | ||
| exceptionFormat "full" | ||
| } | ||
| } | ||
|
|
||
| // Task to run functional profile tests separately | ||
| tasks.register('functionalProfileTest', Test) { | ||
| useJUnitPlatform() | ||
| systemProperty 'geb.env', 'chromeHeadless' | ||
| include '**/*Functional*Profile*Test*' | ||
| include '**/*Functional*Profile*Spec*' | ||
|
|
||
| testLogging { | ||
| events "passed", "skipped", "failed" | ||
| exceptionFormat "full" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| plugins { | ||
| id "com.energizedwork.webdriver-binaries" version "1.4" | ||
| id 'groovy' | ||
| } | ||
|
|
||
| ext { | ||
| spockVersion = '1.2-groovy-2.4' | ||
| gebVersion = '2.3' | ||
| seleniumVersion = '3.14.0' | ||
| seleniumSafariDriverVersion='3.14.0' | ||
| chromeDriverVersion='2.44' | ||
| geckodriverVersion='0.23.0' | ||
| } | ||
|
|
||
| repositories { | ||
| jcenter() | ||
| } | ||
|
|
||
| dependencies { | ||
| testCompile "org.spockframework:spock-core:$spockVersion" | ||
|
|
||
| compile "org.gebish:geb-spock:$gebVersion" | ||
| compile "org.seleniumhq.selenium:selenium-support:$seleniumVersion" | ||
|
|
||
| testRuntime "org.seleniumhq.selenium:selenium-chrome-driver:$seleniumVersion" | ||
| testRuntime "org.seleniumhq.selenium:selenium-firefox-driver:$seleniumVersion" | ||
| testRuntime "org.seleniumhq.selenium:selenium-safari-driver:$seleniumSafariDriverVersion" | ||
| } | ||
|
|
||
| webdriverBinaries { | ||
| chromedriver "$chromeDriverVersion" | ||
| geckodriver "$geckodriverVersion" | ||
| } | ||
|
|
||
| tasks.withType(Test) { | ||
| systemProperty "geb.env", System.getProperty('geb.env') | ||
| testLogging { | ||
| events "passed", "skipped", "failed" | ||
| exceptionFormat 'full' | ||
| } | ||
| } |
18 changes: 18 additions & 0 deletions
18
grails-profiles-tests/functional-tests/src/test/groovy/example/grails/HomePage.groovy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| package example.grails | ||
|
|
||
| import geb.Page | ||
|
|
||
| class HomePage extends Page { | ||
|
|
||
| static url = '/#/' | ||
|
|
||
| static at = { title.contains('Grails') } | ||
|
|
||
| static content = { | ||
| controllers(wait: true) { $('#controllers li') } | ||
| } | ||
|
|
||
| List<String> controllerNames() { | ||
| controllers.collect { it.text() } as List<String> | ||
| } | ||
| } |
22 changes: 22 additions & 0 deletions
22
grails-profiles-tests/functional-tests/src/test/groovy/example/grails/HomeSpec.groovy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| package example.grails | ||
|
|
||
| import geb.Browser | ||
| import geb.spock.GebSpec | ||
| import spock.lang.Requires | ||
|
|
||
| class HomeSpec extends GebSpec { | ||
|
|
||
| //@Requires({ Utils.available('http://localhost:8080') && Utils.available('http://localhost:3000') }) | ||
| def "homage shows a list of available controllers"() { | ||
| given: | ||
| Browser browser = new Browser() | ||
| List<String> expectedControllerNames = ['demo.ApplicationController'] | ||
|
|
||
| when: | ||
| HomePage homePage = browser.to(HomePage) | ||
| List<String> controllerNames = homePage.controllerNames() | ||
|
|
||
| then: | ||
| expectedControllerNames == controllerNames | ||
| } | ||
| } |
18 changes: 18 additions & 0 deletions
18
grails-profiles-tests/functional-tests/src/test/groovy/example/grails/Utils.groovy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| package example.grails | ||
|
|
||
| import groovy.transform.Memoized | ||
|
|
||
| class Utils { | ||
| @Memoized | ||
| static boolean available(String url) { | ||
| try { | ||
| url.toURL().openConnection().with { | ||
| connectTimeout = 1000 | ||
| connect() | ||
| } | ||
| true | ||
| } catch (IOException e) { | ||
| false | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
We do not use travis. Can you please convert this project to a subproject of grails-core?