Gradle Review (5)-test Remote Debug

Source: Internet
Author: User
The "Murder" caused by a sentence


The information in the official document about test has this sentence:


The test process can be started in debug mode (see Getdebug ()) in a ad-hoc manner by supplying the '--DEBUG-JVM ' switch w Hen invoking the build. 

 Gradle Sometesttask--DEBUG-JVM

But if we tap this command at the command line, the following message will appear:


D:\eclipse\workspare\testng_gradl>gradle Clean Test--DEBUG-JVM
: Clean
: Compilejava
: Processresources
: Classes
: Compiletestjava
:p rocesstestresources
: testclasses
: Test
Listening for transport Dt_socket at address:5005

> Building 87% >: Test

The cursor will always blink here, what is the use of it? Had a morning, found an article, suddenly dawned.


This--DEBUG-JVM parameter will listen to the 5005 port information while executing the test, then where does this information come from. I slowly said.


2. Take testng as an example


My test task code is to start the testng test and then output a sentence before the test, and the output information in the test case will be output as well.


Test {
	usetestng ()
	//systemproperty ' Some.prop ', ' value '
	//exclude ' org/gradle/simpletest.class '
	/ /reports.html.enabled = True
	//scanfortestclasses = False
	
	beforetest {Descriptor
      -logger.lifecycle ( "Running Test:" + descriptor)
   }
   onoutput {descriptor, Event-
      -Logger.lifecycle ("Test:" + descriptor + "Produced standard Out/err:" + event.message)
   }
}


This time we started our case in the debug mode in Eclipse. But note that it is not directly debug as->testng. The specific configuration is as follows:



Enter the Debug Configurations interface



The point new will automatically add the class you want to test, but be careful at this time to change the port to the number you are listening to on the command line 5005. If there are other ports on the command line, just follow them.




This time you click on Debug and you will see that the command line has output.


Running Test:test Method Afasttest (org.gradle.SimpleTest)
Test:test method Afasttest (org.gradle.SimpleTest) Produced standard OUT/ERR:FA
St Test

Running Test:test method Aslowtest (org.gradle.SimpleTest)
test:test Method Aslowtest (Org.gradle.SimpleTest) produced standard OUT/ERR:SL
ow test

test:test ' Gradle test ' produced S Tandard out/err:teardown

test:test ' Gradle Test ' produced standard out/err:setup Running

Test:test method Afas TTest1 (Org.gradle.SimpleTest1)
Test:test method AFastTest1 (ORG.GRADLE.SIMPLETEST1) produced standard OUT/ERR:
Fast Test1

Running Test:test Method ASlowTest1 (org.gradle.SimpleTest1)
> Building 87% >: Test > 3 Tests completed

And will wait for the debug case to end. This is the debug mode.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.