Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ ext {

testProjectsStartWith = [
'grails-test-suite',
'grails-test-examples'
'grails-test-examples',
'grails-profiles-tests'
]
testProjects = [ /* Will be populated by subprojects loop below */]
docProjects = [ /* Will be populated by subprojects loop below */]
Expand Down
8 changes: 8 additions & 0 deletions grails-profiles-tests/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.gradle
.idea
build
*.iml
.DS_Store
demo
.project
.settings
98 changes: 98 additions & 0 deletions grails-profiles-tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# 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
- `BasicProfileTests.groovy` - Basic profile functionality tests
- `ProfileIntegrationTests.groovy` - Integration tests for profile functionality
- `ProfileEndToEndTests.groovy` - End-to-end tests for profile functionality

## Running the Tests

### Run all profile tests:
```bash
./gradlew :grails-profiles-tests:test
```

## 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

### Integration Testing
- Application startup
- Configuration validation
- Basic functionality verification

## Dependencies

The tests depend on:
- Grails Core Framework
- Spock testing framework
- TestContainers for containerized testing (when needed)

## Configuration

The tests use containerized browsers through TestContainers integration via Geb's container support.
Geb configurations are located in `src/test/resources/GebConfig.groovy`.

## 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
41 changes: 41 additions & 0 deletions grails-profiles-tests/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
plugins {
id 'groovy'
id 'org.apache.grails.buildsrc.properties'
id 'org.apache.grails.buildsrc.compile'
}

apply from: rootProject.layout.projectDirectory.file('gradle/functional-test-config.gradle')

version = projectVersion
group = 'org.apache.grails.testing'

dependencies {
// Use platform for proper version management
implementation platform(project(':grails-bom'))

implementation project(':grails-core')
implementation project(':grails-bootstrap')
implementation project(':grails-web-boot')

testImplementation project(':grails-test-core')
testImplementation project(':grails-testing-support-core')
testImplementation project(':grails-testing-support-web')

testImplementation 'org.spockframework:spock-core'
testRuntimeOnly 'net.bytebuddy:byte-buddy'
testImplementation 'org.objenesis:objenesis'

testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
testImplementation 'org.slf4j:slf4j-simple'
}

// Configure test tasks
tasks.withType(Test).configureEach {
useJUnitPlatform()
}

test {
include '**/*Spec.class'
include '**/*Tests.class'
include '**/*Test.class'
}
35 changes: 35 additions & 0 deletions grails-profiles-tests/generate-script.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@Grab('org.yaml:snakeyaml:1.23')

File f = new File('travis-build.sh')

f << '#!/bin/bash\n' +
'set -e\n' +
'\n' +
'EXIT_STATUS=0\n\n'

import org.yaml.snakeyaml.Yaml
List commands = new Yaml().load((".travis.yml" as File).text).script

List<String> skipCommands = [
'curl -s get.sdkman.io | bash',
'source "$HOME/.sdkman/bin/sdkman-init.sh"',
'echo sdkman_auto_answer=true > ~/.sdkman/etc/config',
'source "/home/travis/.sdkman/bin/sdkman-init.sh"',
'./gradlew build --console=plain',
'cd build/grails-wrapper/',
'./gradlew assemble',
'cd ../../',
'mkdir -p $HOME/.grails/wrapper',
'cp /home/travis/build/grails/grails-profiles-tests/build/grails-wrapper/wrapper/build/libs/grails4-wrapper-1.0.1.BUILD-SNAPSHOT.jar $HOME/.grails/wrapper/grails4-wrapper.jar',
'sdk install grails dev /home/travis/build/grails/grails-profiles-tests/build/grails-core',
'sdk install grails',
'sdk use grails dev',
'grails --version',
]
commands -= skipCommands
commands.each {
f << "${it} || EXIT_STATUS=\$? \n"
f << '\nif [ $EXIT_STATUS -ne 0 ]; then\n'
f << ' exit $EXIT_STATUS\n'
f << 'fi\n\n\n'
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#Wed Jan 09 13:05:35 CET 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1-all.zip
172 changes: 172 additions & 0 deletions grails-profiles-tests/gradlew

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading