Skip to content
This repository has been archived by the owner on Oct 23, 2022. It is now read-only.

Addition of RunSpecifiedTests support #76

Closed
extremesurfer opened this issue Nov 20, 2016 · 6 comments
Closed

Addition of RunSpecifiedTests support #76

extremesurfer opened this issue Nov 20, 2016 · 6 comments

Comments

@extremesurfer
Copy link

Suggested new feature which we will fork/add and pull request if acceptable.

With large deployments into development environments where test execution can take several hours it is common practice to execute only the tests in the changeset and not the full suite.

It would be beneficial to have capability within the force-dev-tool to support this usecase.

Suggest:

New cli option deployRunSpecifiedTests added to force-dev-tool
Usage:
force-dev-tool deployRunSpecifiedTests [options] [tests] []

Tests: a list of test classes space separated OR use options -m

Options:
-d= Directory containing the metadata and package.xml.
-m=filemask Filemasks of the naming convention in the package.xml that identifies test classes e.g *Test *Mock
-f= Zip file containing the metadata and package.xml.

Filemasks could be consistent with the test run config e.g inside quotes space separated expressions.

So you'd either supply the test classes on the cli, or provide a mask which looks at the classes in the package.xml and matches against the mask, then runs those. This will allow changeset development to only execute the tests in that changeset.

@amtrack
Copy link
Owner

amtrack commented Nov 21, 2016

Hi @extremesurfer,
thank you for your feedback.
I think this is a good idea.

Ideally we should add all of the DeployOptions from https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_deploy.htm as command line flags in a single sub command deploy and get rid of the deployTest, validate and validateTest sub commands.

  1. For the beginning, i suggest to modify lib/cli/deployTest.js to accept a --runTests argument.
    Accordingly, test classes could be specified by e.g. --runTests TestA TestB (or as one argument inside quotes as you mentioned).
    In the case --runTests is not empty, we would have to set testLevel from RunLocalTests to RunSpecifiedTests and add the runTests array to the deployOpts object.

You could then already run

$ force-dev-tool changeset create foo ApexClass/Foo ApexClass/TestFoo ApexClass/MockFoo
$ force-dev-tool deployTest -d config/deployments/foo --runTests TestFoo MockFoo
  1. Further i suggest adding a new sub command (eg. resolve, match or package grep...) that simply resolves patterns against the current package.xml (or org fetch result config/dev-fetch-result.json).
$ force-dev-tool package grep 'ApexClass/Test*' 'ApexClass/Mock*'
ApexClass/TestFoo
ApexClass/MockFoo

You could then combine those commands the unix way to s.th. like this:

$ force-dev-tool changeset create foo ApexClass/Foo ApexClass/TestFoo
$ force-dev-tool package grep 'ApexClass/Test*' 'ApexClass/Mock*' \
 | cut -d '/' -f 2 \
 | xargs force-dev-tool deployTest -d config/deployments/foo --runTests

Does that sound good to you?
If you want to start with 1., i could also try to implement 2.

@extremesurfer
Copy link
Author

Hi, yes that sounds good. We will do 1) hopefully by the end of this week.

@amtrack
Copy link
Owner

amtrack commented Nov 23, 2016

Hi @extremesurfer,
FYI: I started working on 2) in #77.

@mbertram
Copy link

mbertram commented Dec 3, 2016

Hi @amtrack,

I started working on this ticket. It seems like you implemented it in 61b37e2 and already moved the code from the deployTest into the deploy command. Thanks for that.
Is there anything left for this ticket we could help with?

@amtrack
Copy link
Owner

amtrack commented Dec 4, 2016

Hi @mbertram,

yeah, actually i just wanted to add support for the purgeOnDelete option and then i gave this a try as well :-).

I would appreciate if you could checkout the deploy branch to test this and see if this would fit your needs.
Please see the examples from force-dev-tool help deploy (especially regarding xargs -0).
I'll update the README.md when this will be merged.

@amtrack
Copy link
Owner

amtrack commented Feb 6, 2017

Released in v0.13.0

@amtrack amtrack closed this as completed Feb 6, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants