Android Test Monkey - Set Verbosity?

3.3k views Asked by At

How can I change the verbosity level when running Test Monkey from the command line?

These two commands work:

adb shell monkey -p com.my.package 5000
adb shell monkey -p com.my.package -v 5000

The Developer docs say, "Each -v on the command line will increment the verbosity level. Level 0 (the default) provides little information beyond startup notification, test completion, and final results. Level 1 provides more details about the test as it runs, such as individual events being sent to your activities. Level 2 provides more detailed setup information such as activities selected or not selected for testing."

However, when I try adb shell monkey -p com.my.package -v -v 5000 I get a segmentation fault monkey -p com.my....

I tried adb shell monkey -p com.my.package -v 2 5000, but monkey reads 2 as the count, rather than the value for -v.

Help? :)

3

There are 3 answers

1
Francesco Laurita On BEST ANSWER

It should be: adb shell monkey -p com.my.package -vvv 5000

0
aldok On

I don't think segmentation fault is caused by the syntax.

adb shell monkey -p com.my.package -v -v 5000

Perhaps you give too many events (5000), but that's another discussion.

The correct way to increase the verbosity of monkey is repeating -v.

// not verbose
adb shell monkey -p com.my.package 100

// verbose 1
adb shell monkey -p com.my.package -v 100

// verbose 2
adb shell monkey -p com.my.package -v -v 100

// verbose 3
adb shell monkey -p com.my.package -v -v -v 100

You can check the AOSP source code by yourself, under the platform_development/cmds/monkey package.

Monkey.java

while ((opt = nextOption()) != null) {
    if (opt.equals("-s")) {
        mSeed = nextOptionLong("Seed");
    } else if (opt.equals("-v")) {
        mVerbose += 1;

MonkeySourceRandom.java

if (ret && mVerbose >= 2) {
    mPermissionUtil.dump();
}

// if verbose, show factors
if (mVerbose > 0) {
    Logger.out.println("// Event percentages:");
    for (int i = 0; i < FACTORZ_COUNT; ++i) {
        Logger.out.println("//   " + i + ": " + mFactors[i] + "%");
    }
}
1
Pankaj Asegaonkar On

Here is the correct command for the monkey test:

adb.exe shell monkey -p packagename -v 500   ***or***
adb.exe shell monkey -p packagename -v 500 >> log.txt

log.txt--> will created in the tools folder and all test result will store in that txt file.

example:

C:\android-sdk-windows-1.6_r1\android-sdk-windows-1.6_r1\tools>adb.exe shell monkey -p fr.bouyguestelecom.sync -v 500 >> LOG.TXT

fr.bouyguestelecom.sync= is the package name.