1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119<!DOCTYPE html> 120<html devsite> 121<head> 122 123 124 <meta name="top_category" value="develop" /> 125 126 <meta name="subcategory" value="reference" /> 127 128 129 <meta name="book_path" value="/reference/android/support/test/_book.yaml" /> 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145<title>DisableOnAndroidDebug</title> 146 147 148</head> 149 150<body class="gc-documentation develop reference api apilevel-"> 151<div id="doc-api-level" class="" style="display:none"></div> 152 153 154 155 156<div id="naMessage"></div> 157 158<div id="api-info-block"> 159<div class="api-level"> 160 161 162 163 164</div> 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183<div class="sum-details-links"> 184 185Summary: 186 187 188 189 190 191 192 193 194 195 <a href="#pubctors">Ctors</a> 196 197 198 199 200 | <a href="#pubmethods">Methods</a> 201 202 203 204 205 | <a href="#inhmethods">Inherited Methods</a> 206 207| <a href="#" onclick="return toggleAllClassInherited()" id="toggleAllClassInherited">[Expand All]</a> 208 209</div><!-- end sum-details-links --> 210</div><!-- end api-info-block --> 211 212<div class="api apilevel-" id="jd-content"> 213 214<!-- ======== START OF CLASS DATA ======== --> 215 216<h1 class="api-title">DisableOnAndroidDebug</h1> 217<p> 218<code class="api-signature"> 219 public 220 221 222 223 class 224 DisableOnAndroidDebug 225</code> 226<br> 227 228 229<code class="api-signature"> 230 231 extends Object 232 233 234 235</code> 236 237<code class="api-signature"> 238 239 240 implements 241 242 TestRule 243 244 245 246</code> 247 248</p><table class="jd-inheritance-table"> 249 250 251 <tr> 252 253 <td colspan="2" class="jd-inheritance-class-cell">java.lang.Object 254 </td> 255 </tr> 256 257 258 <tr> 259 260 <td class="jd-inheritance-space"> ↳</td> 261 262 <td colspan="1" class="jd-inheritance-class-cell">android.support.test.rule.DisableOnAndroidDebug 263 </td> 264 </tr> 265 266 267</table> 268 269 270 271 272<br><hr> 273 274 275 <p>The <code>DisableOnAndroidDebug</code> Rule allows you to label certain rules to be 276 disabled when debugging. 277 <p> 278 The most illustrative use case is for tests that make use of the 279 <a href="http://junit.org/apidocs/org/junit/rules/Timeout.html"><code>Timeout</code></a> 280 rule, when ran in debug mode the test may terminate on 281 timeout abruptly during debugging. Developers may disable the timeout, or 282 increase the timeout by making a code change on tests that need debugging and 283 remember revert the change afterwards or rules such as 284 <a href="http://junit.org/apidocs/org/junit/rules/Timeout.html"><code>Timeout</code></a> that 285 may be disabled during debugging may be wrapped in a <code>DisableOnDebug</code>. 286 <p> 287 The important benefit of this feature is that you can disable such rules 288 without any making any modifications to your test class to remove them during 289 debugging. 290 <p> 291 This does nothing to tackle timeouts or time sensitive code under test when 292 debugging and may make this less useful in such circumstances. 293 <p> 294 Example usage: 295 296 <pre> 297 public static class DisableTimeoutOnDebugSampleTest { 298 299 @Rule 300 public TestRule timeout = new DisableOnAndroidDebug(new Timeout(20)); 301 302 @Test 303 public void myTest() { 304 int i = 0; 305 assertEquals(0, i); // suppose you had a break point here to inspect i 306 } 307 } 308 </pre> 309</p> 310 311 312 313 314 315 316 317<h2 class="api-section">Summary</h2> 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341<!-- ======== CONSTRUCTOR SUMMARY ======== --> 342<table id="pubctors" class="responsive constructors"> 343<tr><th colspan="2"><h3>Public constructors</h3></th></tr> 344 345 346 347 348 <tr class="api apilevel-" > 349 350 351 <td width="100%"> 352 <code> 353 <a href="/reference/android/support/test/rule/DisableOnAndroidDebug.html#DisableOnAndroidDebug(org.junit.rules.TestRule)">DisableOnAndroidDebug</a>(TestRule rule) 354 </code> 355 356 <p>Wrap another <code><a href="/reference/org/junit/rules/TestRule.html">TestRule</a></code> and conditionally disable it when a debugger is attached. 357 358 359</p> 360 361 </td> 362 </tr> 363 364 365 366</table> 367 368 369 370 371 372 373<!-- ========== METHOD SUMMARY =========== --> 374<table id="pubmethods" class="responsive methods"> 375<tr><th colspan="2"><h3>Public methods</h3></th></tr> 376 377 378 379 380 <tr class="api apilevel-" > 381 382 383 <td><code> 384 385 386 387 final 388 389 Statement</code> 390 </td> 391 392 <td width="100%"> 393 <code> 394 <a href="/reference/android/support/test/rule/DisableOnAndroidDebug.html#apply(org.junit.runners.model.Statement, org.junit.runner.Description)">apply</a>(Statement base, Description description) 395 </code> 396 397 <p> 398 399 400 401</p> 402 403 </td> 404 </tr> 405 406 407 408 <tr class="api apilevel-" > 409 410 411 <td><code> 412 413 414 415 416 417 boolean</code> 418 </td> 419 420 <td width="100%"> 421 <code> 422 <a href="/reference/android/support/test/rule/DisableOnAndroidDebug.html#isDebugging()">isDebugging</a>() 423 </code> 424 425 <p>Returns <code>true</code> if the VM has a debugger connected. 426 427 428</p> 429 430 </td> 431 </tr> 432 433 434 435</table> 436 437 438 439 440 441 442 443<!-- ========== METHOD SUMMARY =========== --> 444<table id="inhmethods" class="methods inhtable"> 445<tr><th><h3>Inherited methods</h3></th></tr> 446 447 448<tr class="api apilevel-" > 449<td colspan="2"> 450 451 <a href="#" onclick="return toggleInherited(this, null)" id="inherited-methods-java.lang.Object" class="jd-expando-trigger closed" 452 ><img height="34" id="inherited-methods-java.lang.Object-trigger" 453 src="/assets/images/styles/disclosure_down.png" 454 class="jd-expando-trigger-img" /></a>From 455class 456<code> 457 458 java.lang.Object 459 460</code> 461<div id="inherited-methods-java.lang.Object"> 462 <div id="inherited-methods-java.lang.Object-list" 463 class="jd-inheritedlinks"> 464 </div> 465 <div id="inherited-methods-java.lang.Object-summary" style="display: none;"> 466 <table class="jd-sumtable-expando responsive"> 467 468 469 470 471 <tr class="api apilevel-" > 472 473 474 <td><code> 475 476 477 478 479 480 Object</code> 481 </td> 482 483 <td width="100%"> 484 <code> 485 clone() 486 </code> 487 488 </td> 489 </tr> 490 491 492 493 <tr class="api apilevel-" > 494 495 496 <td><code> 497 498 499 500 501 502 boolean</code> 503 </td> 504 505 <td width="100%"> 506 <code> 507 equals(Object arg0) 508 </code> 509 510 </td> 511 </tr> 512 513 514 515 <tr class="api apilevel-" > 516 517 518 <td><code> 519 520 521 522 523 524 void</code> 525 </td> 526 527 <td width="100%"> 528 <code> 529 finalize() 530 </code> 531 532 </td> 533 </tr> 534 535 536 537 <tr class="api apilevel-" > 538 539 540 <td><code> 541 542 543 544 final 545 546 Class<?></code> 547 </td> 548 549 <td width="100%"> 550 <code> 551 getClass() 552 </code> 553 554 </td> 555 </tr> 556 557 558 559 <tr class="api apilevel-" > 560 561 562 <td><code> 563 564 565 566 567 568 int</code> 569 </td> 570 571 <td width="100%"> 572 <code> 573 hashCode() 574 </code> 575 576 </td> 577 </tr> 578 579 580 581 <tr class="api apilevel-" > 582 583 584 <td><code> 585 586 587 588 final 589 590 void</code> 591 </td> 592 593 <td width="100%"> 594 <code> 595 notify() 596 </code> 597 598 </td> 599 </tr> 600 601 602 603 <tr class="api apilevel-" > 604 605 606 <td><code> 607 608 609 610 final 611 612 void</code> 613 </td> 614 615 <td width="100%"> 616 <code> 617 notifyAll() 618 </code> 619 620 </td> 621 </tr> 622 623 624 625 <tr class="api apilevel-" > 626 627 628 <td><code> 629 630 631 632 633 634 String</code> 635 </td> 636 637 <td width="100%"> 638 <code> 639 toString() 640 </code> 641 642 </td> 643 </tr> 644 645 646 647 <tr class="api apilevel-" > 648 649 650 <td><code> 651 652 653 654 final 655 656 void</code> 657 </td> 658 659 <td width="100%"> 660 <code> 661 wait(long arg0, int arg1) 662 </code> 663 664 </td> 665 </tr> 666 667 668 669 <tr class="api apilevel-" > 670 671 672 <td><code> 673 674 675 676 final 677 678 void</code> 679 </td> 680 681 <td width="100%"> 682 <code> 683 wait(long arg0) 684 </code> 685 686 </td> 687 </tr> 688 689 690 691 <tr class="api apilevel-" > 692 693 694 <td><code> 695 696 697 698 final 699 700 void</code> 701 </td> 702 703 <td width="100%"> 704 <code> 705 wait() 706 </code> 707 708 </td> 709 </tr> 710 711 712 713 </table> 714 </div> 715</div> 716</td></tr> 717 718 719 720<tr class="api apilevel-" > 721<td colspan="2"> 722 723 <a href="#" onclick="return toggleInherited(this, null)" id="inherited-methods-org.junit.rules.TestRule" class="jd-expando-trigger closed" 724 ><img height="34" id="inherited-methods-org.junit.rules.TestRule-trigger" 725 src="/assets/images/styles/disclosure_down.png" 726 class="jd-expando-trigger-img" /></a>From 727interface 728<code> 729 730 org.junit.rules.TestRule 731 732</code> 733<div id="inherited-methods-org.junit.rules.TestRule"> 734 <div id="inherited-methods-org.junit.rules.TestRule-list" 735 class="jd-inheritedlinks"> 736 </div> 737 <div id="inherited-methods-org.junit.rules.TestRule-summary" style="display: none;"> 738 <table class="jd-sumtable-expando responsive"> 739 740 741 742 743 <tr class="api apilevel-" > 744 745 746 <td><code> 747 abstract 748 749 750 751 752 Statement</code> 753 </td> 754 755 <td width="100%"> 756 <code> 757 apply(Statement arg0, Description arg1) 758 </code> 759 760 </td> 761 </tr> 762 763 764 765 </table> 766 </div> 767</div> 768</td></tr> 769 770 771</table> 772 773 774 775<!-- XML Attributes --> 776 777 778<!-- Enum Values --> 779 780 781<!-- Constants --> 782 783 784<!-- Fields --> 785 786 787<!-- Public ctors --> 788 789 790<!-- ========= CONSTRUCTOR DETAIL ======== --> 791<h2 class="api-section">Public constructors</h2> 792 793 794 795<A NAME="DisableOnAndroidDebug(org.junit.rules.TestRule)"></A> 796 797<div class="api apilevel-"> 798 <h3 class="api-name">DisableOnAndroidDebug</h3> 799 <div class="api-level"> 800 <div></div> 801 802 803 804 </div> 805<pre class="api-signature no-pretty-print"> 806DisableOnAndroidDebug (TestRule rule)</pre> 807 808 809 810 811 <p>Wrap another <code><a href="/reference/org/junit/rules/TestRule.html">TestRule</a></code> and conditionally disable it when a debugger is attached.</p> 812 <table class="responsive"> 813 <tr><th colspan=2>Parameters</th></tr> 814 <tr> 815 <td><code>rule</code></td> 816 <td width="100%"> 817 <code>TestRule</code>: 818 to disable during debugging 819</td> 820 </tr> 821 </table> 822 823</div> 824 825 826 827 828 829<!-- ========= CONSTRUCTOR DETAIL ======== --> 830<!-- Protected ctors --> 831 832 833 834<!-- ========= METHOD DETAIL ======== --> 835<!-- Public methdos --> 836 837<h2 class="api-section">Public methods</h2> 838 839 840 841<A NAME="apply(org.junit.runners.model.Statement, org.junit.runner.Description)"></A> 842 843<div class="api apilevel-"> 844 <h3 class="api-name">apply</h3> 845 <div class="api-level"> 846 <div></div> 847 848 849 850 </div> 851<pre class="api-signature no-pretty-print"> 852Statement apply (Statement base, 853 Description description)</pre> 854 855 856 857 858 <p> 859</p> 860 <table class="responsive"> 861 <tr><th colspan=2>Parameters</th></tr> 862 <tr> 863 <td><code>base</code></td> 864 <td width="100%"> 865 <code>Statement</code> 866 <!-- no parameter comment --></td> 867 </tr> 868 <tr> 869 <td><code>description</code></td> 870 <td width="100%"> 871 <code>Description</code> 872 <!-- no parameter comment --></td> 873 </tr> 874 </table> 875 <table class="responsive"> 876 <tr><th colspan=2>Returns</th></tr> 877 <tr> 878 <td><code>Statement</code></td> 879 <td width="100%"><!-- no returns description in source --></td> 880 </tr> 881 </table> 882 883</div> 884 885 886<A NAME="isDebugging()"></A> 887 888<div class="api apilevel-"> 889 <h3 class="api-name">isDebugging</h3> 890 <div class="api-level"> 891 <div></div> 892 893 894 895 </div> 896<pre class="api-signature no-pretty-print"> 897boolean isDebugging ()</pre> 898 899 900 901 902 <p>Returns <code>true</code> if the VM has a debugger connected. This method may be used by test 903 classes to take additional action to disable code paths that interfere with debugging if 904 required.</p> 905 <table class="responsive"> 906 <tr><th colspan=2>Returns</th></tr> 907 <tr> 908 <td><code>boolean</code></td> 909 <td width="100%"><code>true</code> if a debugger is connected, <code>false</code> otherwise 910</td> 911 </tr> 912 </table> 913 914</div> 915 916 917 918 919 920<!-- ========= METHOD DETAIL ======== --> 921 922 923 924<!-- ========= END OF CLASS DATA ========= --> 925 926</div><!-- end jd-content --> 927 928 929 930<div class="data-reference-resources-wrapper"> 931 932 <ul data-reference-resources> 933 934 935 936 <li><h2>Classes</h2> 937 <ul> 938 <li class="api apilevel-"><a href="/reference/android/support/test/rule/ActivityTestRule.html">ActivityTestRule</a></li> 939 <li class="selected api apilevel-"><a href="/reference/android/support/test/rule/DisableOnAndroidDebug.html">DisableOnAndroidDebug</a></li> 940 <li class="api apilevel-"><a href="/reference/android/support/test/rule/ServiceTestRule.html">ServiceTestRule</a></li> 941 <li class="api apilevel-"><a href="/reference/android/support/test/rule/UiThreadTestRule.html">UiThreadTestRule</a></li> 942 </ul> 943 </li> 944 945 946 947 </ul> 948 949</div> 950 951 952 953</body> 954</html> 955