Filters for Espresso Tests
Usually, all the test cases of your Espresso test suite are executed, but there is a way to filter these. You can use Espresso test runner (typically AndroidJUnitRunner
), which provides you with multiple options to filter the test cases which you want to execute.
To filter the test cases, you just need to pass the suitable parameters in LambdaTest’s REST API request. Refer to the table below to understand how to use various filters provided by LambdaTest.
Given below is the REST API endpoint:
POST /framework/v1/espresso/build
Parameters | Description | Values | Datatype |
---|---|---|---|
package | Allows the user to only run specific packages defined | Multiple packages can be passed in comma-separated format. E.g. ["com.example.proverbial.packagename"] | Array |
skipPackage | Allows the user to run all packages except the ones defined | Multiple packages can be passed in comma-separated format. E.g. ["com.example.proverbial.packagename"] | Array |
class | Allows the user to only run specific classes defined | Multiple classes can be passed in comma-separated format. E.g. ["com.example.proverbial.packagename.classname"] | Array |
skipClass | Allows the user to run all classes except the ones defined | Multiple classes can be passed in comma-separated format. E.g. ["com.example.proverbial.packagename.classname"] | Array |
annotation | Allows the user to only run specific annotations defined | Only a single annotation can be passed. E.g. "com.example.proverbial.annotation" | String |
skipAnnotation | Allows the user to run all annotations except the ones defined | Only a single annotation can be passed. E.g. "com.example.proverbial.annotation" | String |
size | Allows the user to run only tests that are annotated with the matching size value @SmallTest, @MediumTest or @LargeTest | You may specify only one value for this property from the three valid values i.e. "small", "medium", "large" | String |
Note
You can not use the following filters simultaneously.
class
andpackage
class
andskipClass
annotation
andskipAnnotation
package
andskipPackage
Some Examples
Please refer to the example cURL
requests given below for your reference.
1. To run specifically defined packages
- MacOS/Linux
- Windows
curl --location --request POST 'https://mobile-api.lambdatest.com/framework/v1/espresso/build' \
--header 'Authorization: Basic <Enter_Basic_Auth>' \
--header 'Content-Type: application/json' \
--data-raw '{
"app" : "lt://APP_ID",
"testSuite": "lt://TestSuite_ID",
"device" : ["Pixel 6-12"],
"queueTimeout": 360,
"IdleTimeout": 150,
"deviceLog": true,
"build" : "Proverbial-Espresso"
"package" : ["com.example.proverbial.packagename1","com.example.proverbial.packagename2"]
}'
{`curl --location --request POST "https://mobile-api.lambdatest.com/framework/v1/espresso/build" --header "Content-Type: application/json" --header "Authorization: Basic <Enter the Auth here>" --data-raw "{\"app\" : \"lt://APP_ID\",\"testSuite\": \"lt://APP_ID\",\"device\" : [\"Pixel 6-12\"],\"queueTimeout\": 360,\"IdleTimeout\": 150,\"deviceLog\": true,\"network\": false,\"build\" : \"Proverbial-Espresso\",\"geoLocation\" : \"FR\", \"package\" : [\"com.example.proverbial.packagename1\", \"com.example.proverbial.packagename2\"]}"`}
2. To run specifically defined classes
- MacOS/Linux
- Windows
curl --location --request POST 'https://mobile-api.lambdatest.com/framework/v1/espresso/build' \
--header 'Authorization: Basic <Enter_Basic_Auth>' \
--header 'Content-Type: application/json' \
--data-raw '{
"app" : "lt://APP_ID",
"testSuite": "lt://TestSuite_ID",
"device" : ["Pixel 6-12"],
"queueTimeout": 360,
"IdleTimeout": 150,
"deviceLog": true,
"build" : "Proverbial-Espresso"
"class" : ["com.example.proverbial.packagename.classname1","com.example.proverbial.packagename.classname2"]
}'
{`curl --location --request POST "https://mobile-api.lambdatest.com/framework/v1/espresso/build" --header "Content-Type: application/json" --header "Authorization: Basic <Enter the Auth here>" --data-raw "{\"app\" : \"lt://APP_ID\",\"testSuite\": \"lt://APP_ID\",\"device\" : [\"Pixel 6-12\"],\"queueTimeout\": 360,\"IdleTimeout\": 150,\"deviceLog\": true,\"network\": false,\"build\" : \"Proverbial-Espresso\",\"geoLocation\" : \"FR\", \"class\" : [\"com.example.proverbial.packagename.classname1\",\"com.example.proverbial.packagename.classname2\"]}"`}
3. To run specifically defined annotations
- MacOS/Linux
- Windows
curl --location --request POST 'https://mobile-api.lambdatest.com/framework/v1/espresso/build' \
--header 'Authorization: Basic <Enter_Basic_Auth>' \
--header 'Content-Type: application/json' \
--data-raw '{
"app" : "lt://APP_ID",
"testSuite": "lt://TestSuite_ID",
"device" : ["Pixel 6-12"],
"queueTimeout": 360,
"IdleTimeout": 150,
"deviceLog": true,
"build" : "Proverbial-Espresso"
"annotation" : "com.example.proverbial.annotation"
}'
{`curl --location --request POST "https://mobile-api.lambdatest.com/framework/v1/espresso/build" --header "Content-Type: application/json" --header "Authorization: Basic <Enter the Auth here>" --data-raw "{\"app\" : \"lt://APP_ID\",\"testSuite\": \"lt://APP_ID\",\"device\" : [\"Pixel 6-12\"],\"queueTimeout\": 360,\"IdleTimeout\": 150,\"deviceLog\": true,\"network\": false,\"build\" : \"Proverbial-Espresso\",\"geoLocation\" : \"FR\", \"annotation\" : \"com.example.proverbial.annotation\"}"`}