Closed shreyagoyal06 closed 3 months ago
Hi @shreyagoyal06,
My guess here is the xq command is not in the PATH.
I think it is because you install yq
from its binary and so it only copie yq
and not the other executable.
Could you try installing yq
using apt get and see if it copies all the executable and put them in the PATH ?
Hi @scolladon The sudo command was not working either so I had to update the command like this curl -L https://github.com/mikefarah/yq/releases/download/v4.34.2/yq_linux_amd64 -o yq chmod +x yq mkdir -p $HOME/bin mv yq $HOME/bin/ export PATH=$HOME/bin:$PATH yq --version yq eval -P -o=json package/package.xml | jq '.Package.types | [.] | flatten | map(select(.name=="ApexClass")) | .[] | .members | [.] | flatten | map(select(. | index("*") | not)) | unique | join(",")' > testclass.txt
But the output of this command is just the name of the apex classes that are present in my package.xml. Its not providing the test class names to input into the SF command for RunSpecifiedTest attribute. Can you please enlighten me on this?
Hi @shreyagoyal06, maybe you want to get only the test classes from the package.xml
following a file pattern or you want to deduce the test classes to run from the one in the package.xml
following a file pattern.
In this case you need to update a bit the query and here are some examples.
Hi @scolladon Thank you so much for the solution provided. It resolved one of the test class issue. I used the 3rd pattern provided by you .Package.types | [.] | flatten | map(select(.name=="ApexClass")) | .[] | .members | [.] | flatten | map(select(. | index("*") | not)) | map(. | sub("TEST$" ; "") + "TEST") | unique | join(",")
But instead of appending "Test" to the classes which does not have a test class in the package.xml, is it possible somehow that we can get its test class name from the force-app/main/default/classes folder instead? Because though it is a standard practice for test class naming convention, there might be a possibility that the test classes are named differently.
How the script would know what test class to add depending on classes found in the package.xml ? I think there could be multiple answers to this question and all involved having to script something more complicated than the jq script to fulfil this requirement.
My bet is your better off renaming the test classes to follow a pattern and use the jq script 👍
Okay, thanks for your time and support.
Issue verification check:
What is the problem?
How do I run only specified test classes while deploying to SF environment?
Its mentioned in the doc to use the 'xq' command but when I'm trying to install yq its installs correctly and shows the yq version as well after it when running the xq command provided in the documentation it shows "command not found"
below is the sample yml
Provide the command and the parameters you used Provided the yml above
What is the expected result?
to get test class names in testclass.txt file
What is the actual result?
xq:command not found