Skip to content
Open
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
2 changes: 1 addition & 1 deletion .secrets.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -2033,7 +2033,7 @@
"hashed_secret": "c042bdfc4bc5516ec716afe9e85c173b614ff9f5",
"is_secret": false,
"is_verified": false,
"line_number": 835,
"line_number": 900,
"type": "Hex High Entropy String",
"verified_result": null
}
Expand Down
4 changes: 3 additions & 1 deletion docs/content/releases/posts/v0.46.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ links:
- The user can also be set when submitting tests with the Runs API. [See the REST API reference](../../docs/reference/rest-api/index.html).
- Runs can now be queried by user in the `galasactl runs get` command with the `--user` flag. This will return any runs where the `user` or `requestor` matches the value passed in with the `--user` flag. [See the command reference](../../docs/reference/cli-syntax/galasactl_runs_get.md).

- Added `galasactl tags` commands to the Galasa CLI tool that can be used to create, read, update, and delete test tags as resources on the Galasa service. [See the command reference for more details](../../docs/reference/cli-syntax/galasactl_tags.md)
- Added `galasactl tags` commands to the Galasa CLI tool that can be used to create, read, update, and delete test tags as resources on the Galasa service. [See the command reference for more details](../../docs/reference/cli-syntax/galasactl_tags.md).
- Tags can be assigned a `priority` modifier that can affect the order in which tests submitted to a Galasa service are scheduled. Test submitted with tags that have higher priority modifiers will be scheduled before tests that have no tags or tags with lower priority modifiers.
- Tags can also be assigned a `description` which can be used to provide more information about the tag.

- `galasactl runs submit local` commands can now be supplied with one or more `--methods` flags to run a selection of test methods locally from a Galasa test class that is provided with the `--class` flag. [See the command reference for more details](../../docs/reference/cli-syntax/galasactl_runs_submit_local.md).
17 changes: 15 additions & 2 deletions modules/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -312,14 +312,27 @@ such as cleaning up resources when things fail and arbitrating contention for li
between competing tests. It should only be used during test development to verify that the test is
behaving correctly.

### Example : Run a single test in the local JVM.
### Example: Run a single test class in the local JVM.
```
galasactl runs submit local --log -
--obr mvn:dev.galasa.example.banking/dev.galasa.example.banking.obr/0.0.1-SNAPSHOT/obr
--class dev.galasa.example.banking.account/dev.galasa.example.banking.account.TestAccount
```

### Example : Run a single Gherkin test in the local JVM.
### Example: Run a single test method in the local JVM.

To run a single test method within a test class, supply the `--methods` flag into the `galasactl runs submit local` command.

For example, to run the `testCreateAccount` method within the `TestAccount` class, use the following command:

```
galasactl runs submit local --log -
--obr mvn:dev.galasa.example.banking/dev.galasa.example.banking.obr/0.0.1-SNAPSHOT/obr
--class dev.galasa.example.banking.account/dev.galasa.example.banking.account.TestAccount
--methods testCreateAccount
```

### Example: Run a single Gherkin test in the local JVM.
```
galasactl runs submit local --log -
--gherkin file:///path/to/gherkin/file.feature
Expand Down
4 changes: 4 additions & 0 deletions modules/cli/docs/generated/errors-list.md
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,10 @@ The `galasactl` tool can generate the following errors:
- GAL1271E: Failed to get tags from the Galasa service. Unexpected http status code {} received from the server. Error details from the server are not in the json format.
- GAL1272E: Failed to get tags from the Galasa service. Sending the put request to the Galasa service failed. Cause is {}
- GAL1273E: User '{}' specified with the --user flag does not have permission to launch tests.
- GAL1274E: Invalid Java method name. Method name should not be blank. Use the --help flag for more information, or refer to the documentation at https://galasa.dev/docs/reference
- GAL1275E: Invalid Java method name '{}' should start with a letter (a-z, A-Z), not '{}'. Use the --help flag for more information, or refer to the documentation at https://galasa.dev/docs/reference
- GAL1276E: Invalid Java method name '{}' should not contain the '{}' character. Use the --help flag for more information, or refer to the documentation at https://galasa.dev/docs/reference
- GAL1277E: Invalid Java method name. Method name '{}' is a reserved Java keyword. Use the --help flag for more information, or refer to the documentation at https://galasa.dev/docs/reference
- GAL2000W: Warning: Maven configuration file settings.xml should contain a reference to a Galasa repository so that the galasa OBR can be resolved. The official release repository is '{}', and 'pre-release' repository is '{}'
- GAL2501I: Downloaded {} artifacts to folder '{}'

Expand Down
1 change: 1 addition & 0 deletions modules/cli/docs/generated/galasactl_runs_submit_local.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ galasactl runs submit local [flags]
--gherkin strings Gherkin feature file URL. Should start with 'file://'.
-h, --help Displays the options for the 'runs submit local' command.
--localMaven string The url of a local maven repository are where galasa bundles can be loaded from on your local file system. Defaults to your home .m2/repository file. Please note that this should be in a URL form e.g. 'file:///Users/myuserid/.m2/repository', or 'file://C:/Users/myuserid/.m2/repository'
--methods strings Optional. The names of the Java test methods from the test class provided via the --class option that you wish to run. Method names must start with a letter (a-z, A-Z), can contain letters, numbers, and underscores, and must not be a Java reserved keyword. If not specified, all methods in the given class are run. Method names are case sensitive. This option can only be used alongside --class and cannot be used with --gherkin.
--obr strings The maven coordinates of the obr bundle(s) which refer to your test bundles. The format of this parameter is 'mvn:${TEST_OBR_GROUP_ID}/${TEST_OBR_ARTIFACT_ID}/${TEST_OBR_VERSION}/obr' Multiple instances of this flag can be used to describe multiple obr bundles.
--remoteMaven string the url of the remote maven where galasa bundles can be loaded from. Defaults to maven central. (default "https://repo.maven.apache.org/maven2")
```
Expand Down
7 changes: 7 additions & 0 deletions modules/cli/pkg/cmd/runsSubmitLocal.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,20 @@ func (cmd *RunsSubmitLocalCommand) createRunsSubmitLocalCobraCmd(
"The connection is established using the --debugMode and --debugPort values.",
)

runsSubmitLocalCobraCmd.Flags().StringSliceVar(&cmd.values.runsSubmitLocalCmdParams.TestMethods, "methods", make([]string, 0),
"Optional. The names of the Java test methods from the test class provided via the --class option that you wish to run."+
" Method names must start with a letter (a-z, A-Z), can contain letters, numbers, and underscores, and must not be a Java reserved keyword."+
" If not specified, all methods in the given class are run. Method names are case sensitive."+
" This option can only be used alongside --class and cannot be used with --gherkin.")

runs.AddClassFlag(runsSubmitLocalCobraCmd, cmd.values.submitLocalSelectionFlags, false, "test class names."+
" The format of each entry is osgi-bundle-name/java-class-name. Java class names are fully qualified. No .class suffix is needed.")

runs.AddGherkinFlag(runsSubmitLocalCobraCmd, cmd.values.submitLocalSelectionFlags, false, "Gherkin feature file URL. Should start with 'file://'. ")

runsSubmitLocalCobraCmd.MarkFlagsRequiredTogether("class", "obr")
runsSubmitLocalCobraCmd.MarkFlagsOneRequired("class", "gherkin")
runsSubmitLocalCobraCmd.MarkFlagsMutuallyExclusive("methods", "gherkin")

runsSubmitCmd.CobraCommand().AddCommand(runsSubmitLocalCobraCmd)

Expand Down
16 changes: 16 additions & 0 deletions modules/cli/pkg/cmd/runsSubmitLocal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,22 @@ func TestRunsSubmitLocalGalasaVersionFlagReturnsOk(t *testing.T) {
assert.Contains(t, cmd.Values().(*RunsSubmitLocalCmdValues).runsSubmitLocalCmdParams.TargetGalasaVersion, "0.1.0")
}

func TestRunsSubmitLocalWithGherkinAndMethodsFlagsErrors(t *testing.T) {
// Given...
factory := utils.NewMockFactory()
commandCollection, cmd := setupTestCommandCollection(COMMAND_NAME_RUNS_SUBMIT_LOCAL, factory, t)

var args []string = []string{"runs", "submit", "local", "--gherkin", "my.gherkin.feature", "--methods", "mymethod"}

// When...
err := commandCollection.Execute(args)

// Then...
assert.NotNil(t, err)
assert.ErrorContains(t, err, "if any flags in the group [methods gherkin] are set none of the others can be")
assert.Contains(t, cmd.Values().(*RunsSubmitLocalCmdValues).runsSubmitLocalCmdParams.TestMethods, "mymethod")
}

func TestRunsSubmitLocalLocalMavenFlagReturnsOk(t *testing.T) {
// Given...
factory := utils.NewMockFactory()
Expand Down
8 changes: 7 additions & 1 deletion modules/cli/pkg/errors/errorMessage.go
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,12 @@ var (
GALASA_ERROR_GET_TAGS_EXPLANATION_NOT_JSON = NewMessageType("GAL1271E: Failed to get tags from the Galasa service. Unexpected http status code %v received from the server. Error details from the server are not in the json format.", 1271, STACK_TRACE_NOT_WANTED)
GALASA_ERROR_GET_TAGS_REQUEST_FAILED = NewMessageType("GAL1272E: Failed to get tags from the Galasa service. Sending the put request to the Galasa service failed. Cause is %v", 1272, STACK_TRACE_NOT_WANTED)

// Java method name validation errors
GALASA_ERROR_METHOD_NAME_BLANK = NewMessageType("GAL1274E: Invalid Java method name. Method name should not be blank."+SEE_COMMAND_REFERENCE, 1274, STACK_TRACE_NOT_WANTED)
GALASA_ERROR_INVALID_FIRST_CHAR_IN_METHOD_NAME = NewMessageType("GAL1275E: Invalid Java method name '%s' should start with a letter (a-z, A-Z), not '%s'."+SEE_COMMAND_REFERENCE, 1275, STACK_TRACE_NOT_WANTED)
GALASA_ERROR_INVALID_CHAR_IN_METHOD_NAME = NewMessageType("GAL1276E: Invalid Java method name '%s' should not contain the '%s' character."+SEE_COMMAND_REFERENCE, 1276, STACK_TRACE_NOT_WANTED)
GALASA_ERROR_INVALID_METHOD_RESERVED_WORD = NewMessageType("GAL1277E: Invalid Java method name. Method name '%s' is a reserved Java keyword."+SEE_COMMAND_REFERENCE, 1277, STACK_TRACE_NOT_WANTED)

// Warnings...
GALASA_WARNING_MAVEN_NO_GALASA_OBR_REPO = NewMessageType("GAL2000W: Warning: Maven configuration file settings.xml should contain a reference to a Galasa repository so that the galasa OBR can be resolved. The official release repository is '%s', and 'pre-release' repository is '%s'", 2000, STACK_TRACE_WANTED)

Expand All @@ -509,5 +515,5 @@ var (
// >>> Unit tests guarantee that this number is 'free' to use for a new error message.
// >>> If you do use this number for a new error template, please increment this value.
// >>>
GALxxx_NEXT_MESSAGE_NUMBER_TO_USE = 1274
GALxxx_NEXT_MESSAGE_NUMBER_TO_USE = 1278
)
22 changes: 21 additions & 1 deletion modules/cli/pkg/launcher/jvmLauncher.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ type RunsSubmitLocalCmdParameters struct {

// A string containing the url of the gherkin test file to be exceuted
GherkinURL string

// A list of strings containing a selection of test methods to be run.
TestMethods []string
}

const (
Expand Down Expand Up @@ -257,6 +260,16 @@ func (launcher *JvmLauncher) SubmitTestRun(
err = checkGherkinURLisValid(gherkinURL)
}

if err == nil {
// Validate test methods if provided
for _, method := range launcher.cmdParams.TestMethods {
err = utils.ValidateJavaMethodName(method)
if err != nil {
break
}
}
}

if err == nil {

var jwt = ""
Expand All @@ -279,7 +292,7 @@ func (launcher *JvmLauncher) SubmitTestRun(
launcher.bootstrapProps,
launcher.galasaHome,
launcher.fileSystem, launcher.javaHome, obrs,
*testClassToLaunch, launcher.cmdParams.RemoteMaven, launcher.cmdParams.LocalMaven,
*testClassToLaunch, launcher.cmdParams.TestMethods, launcher.cmdParams.RemoteMaven, launcher.cmdParams.LocalMaven,
launcher.cmdParams.TargetGalasaVersion, overridesFilePath,
gherkinURL,
isTraceEnabled,
Expand Down Expand Up @@ -606,6 +619,7 @@ func getCommandSyntax(
javaHome string,
testObrs []utils.MavenCoordinates,
testLocation TestLocation,
testMethods []string,
remoteMaven string,
localMaven string,
galasaVersionToRun string,
Expand Down Expand Up @@ -655,6 +669,12 @@ func getCommandSyntax(
// --test ${TEST_BUNDLE}/${TEST_JAVA_CLASS}
args = append(args, "--test")
args = append(args, testLocation.OSGiBundleName+"/"+testLocation.QualifiedJavaClassName)

// --methods ${TEST_METHOD}
for _, method := range testMethods {
args = append(args, "--methods")
args = append(args, method)
}
}
}

Expand Down
Loading
Loading