Skip to main content

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
ParametersDescriptionValuesDatatype
packageAllows the user to only run specific packages definedMultiple packages can be passed in comma-separated format. E.g. ["com.example.proverbial.packagename"]Array
skipPackageAllows the user to run all packages except the ones definedMultiple packages can be passed in comma-separated format. E.g. ["com.example.proverbial.packagename"]Array
classAllows the user to only run specific classes definedMultiple classes can be passed in comma-separated format. E.g. ["com.example.proverbial.packagename.classname"]Array
skipClassAllows the user to run all classes except the ones definedMultiple classes can be passed in comma-separated format. E.g. ["com.example.proverbial.packagename.classname"]Array
annotationAllows the user to only run specific annotations definedOnly a single annotation can be passed. E.g. "com.example.proverbial.annotation"String
skipAnnotationAllows the user to run all annotations except the ones definedOnly a single annotation can be passed. E.g. "com.example.proverbial.annotation"String
sizeAllows the user to run only tests that are annotated with the matching size value @SmallTest, @MediumTest or @LargeTestYou 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 and package
  • class and skipClass
  • annotation and skipAnnotation
  • package and skipPackage

Some Examples

Please refer to the example cURL requests given below for your reference.

1. To run specifically defined packages

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"]
}'

2. To run specifically defined classes

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"]
}'

3. To run specifically defined annotations

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"
}'

Test across 3000+ combinations of browsers, real devices & OS.

Book Demo

Help and Support

Related Articles