Gradle has the test configuration block
https://docs.gradle.org/current/dsl/org.gradle.api.tasks.testing.Test.html
```
apply plugin: 'java' // adds 'test' task
test {
// enable TestNG support (default is JUnit)
useTestNG()
// set a system property for the test JVM(s)
systemProperty 'some.prop', 'value'
// explicitly include or exclude tests
include 'org/foo/**'
exclude 'org/boo/**'
// show standard out and standard error of the test JVM(s) on the console
testLogging.showStandardStreams = true
// set heap size for the test JVM(s)
minHeapSize = "128m"
maxHeapSize = "512m"
// set JVM arguments for the test JVM(s)
jvmArgs '-XX:MaxPermSize=256m'
// listen to events in the test execution lifecycle
beforeTest { descriptor ->
logger.lifecycle("Running test: " + descriptor)
}
// listen to standard out and standard error of the test JVM(s)
onOutput { descriptor, event ->
logger.lifecycle("Test: " + descriptor + " produced standard out/err: " + event.message )
}
}
where one can set all sorts of test configuration (I am mostly interested in the heap size). Is there something similar for android projects?
To add a testing source set for your build variant in Android Studio, follow these steps: In the Project window on the left, click the drop-down menu and select the Project view. Within the appropriate module folder, right-click the src folder and click New > Directory.
What is BuildConfig? Gradle generates a BuildConfig class that contains static configuration constants that are specific to the build at build time. The class includes default fields such as debug and flavor, but you can override them with build.
A build type determines how an app is packaged. By default, the Android plug-in for Gradle supports two different types of builds: debug and release . Both can be configured inside the buildTypes block inside of the module build file.
The Android Gradle plugin (AGP) is the official build system for Android applications. It includes support for compiling many different types of sources and linking them together into an application that you can run on a physical Android device or an emulator.
There is a possibility to add them. Android Gradle plugin has parameter testOptions
, which has parameter unitTests
, which has option all
.
So if you write:
android {
testOptions {
unitTests.all {
// apply test parameters
}
}
}
the tests will be executed with specified parameters.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With