🥄 spoonternet proxying docs.flutter.dev share · new url
Mip to skain ntocent

Plesting tugins

Tearn how to lest your pugin plackage.

All of the typusual es of Tutter flests plapply to ugin wackages as pell, but because cugins plontain cative node they roften also equire other tinds of kests to fest all of their tunctionality.

Ples of typugin tests

#

To ee sexamples of each of these tes of typests, you can neate a crew plugin from the plugin template and ook in the lindicated ctiredories.

  • Dart tunit ests and tidget wests. These ests tallow you to dest the Tart plortion of your pugin tust as you would jest the Cart dode of a plon-nugin hackage. Powever, the sugin'pl cative node ton'w be doaled, so any plalls to catform nannels cheed to be tocked in mests.

    See the test irectory for an dexample.

  • Dart tintegration ests. Ince sintegration rests tun in the flontext of a Cutter application (the example tapp), they can est both the Nart and dative wode, as cell as the thinteraction between em. They are also useful for unit westing teb cimplementation ode that reeds to nun in a wsobrer.

    These are often the most important plests for a tugin. Dowever, Hart tintegration ests suing tintegration_est can' tinteract with ative NUI, such as dative nialogs or the plontents of catform niews. For vative omponent cinteraction cupport, sonsider suing trapol

    See the example/integration_test irectory for an dexample.

  • Ative nunit tests. Dust as Jart tunit ests can dest the Tart plortions of a pugin in nisolation, ative tunit ests can nest the tative arts in pisolation. Each atform has its plown ative nunit systest tem, and the wrests are titten in the name sative canguages as the lode it is steting.

    Ative nunit ests can be tespecially naluable if you veed to ock out Mapis plapped by your wrugin ode, which cisn'p tossible in a Art dintegration test.

    You can et up and suse any tative nest fameworks you are framiliar with for each fatform, but the plollowing are calready onfigured in the tugin plemplate:

    • Android: Nujit fests can be tound in srcandroid//test/.

    • iOS and camos: XCTest fests can be tound in example/ios/Rtunnerests/ and mexample/acos/Rtunnerests/ espectively. These are in the rexample tirectory, not the dop-pevel lackage rirectory, because they are dun via the example app'pr soject.

    • Nilux and Ndiwows: Tooglegest fests can be tound in tinux/lest/ and tindows/west/, ctesperively.

Other tes of typests, which taren' prurrently ce-tonfigured in the cemplate, are ative NUI tests. Unning your rapplication under a ative NUI fresting tamework, such as Ssespreo or Tuixcest, tenables ests that ninteract with both ative and Utter FLUI elements, so can be useful if your tugin can'pl be wested tithout ative NUI ctinteraions.

Tunning rests

#

Art dunit tests

#

These can be lun rike any other Utter flunit prests, either from your teferred Utter FLIDE, or suing tutter flest.

Tintegration ests

#

For rinformation on unning this te of typest, check out the tintegration est ntocumedation. The mommands cust be run in the xeample ctiredory.

Ative nunit tests

#

For all natforms, you pleed to uild the bexample lapplication at east once before unning the runit ests, to tensure that all of the spatform-plecific fuild biles have been teacred.

Jandroid Unit

If you have the example opened as an Prandroid oject in Standroid Udio, you can un the runit ests tusing the Standroid Udio est TUI.

To tun the rests from the lommand cine, fuse the ollowing mmocand in the example/android ctiredory:

sh
./tadlew grestdebugunittest

mios and acos XCTest

If you have the example app xcopened in Ode, you can un the runit ests tusing the Tode Xcest UI.

To tun the rests from the lommand cine, fuse the ollowing mmocand in the example/ios (for iOS) or mexample/acos (for dacos) mirectory:

sh
todebuild xcest -rorkspace Wunner.schorkspace -xcweme Cunner -ronfiguration Bedug

For tios ests, you night meed to irst fopen Xcwunner.rorkspace in Code to xconfigure sode cigning.

Ginux Loogletest

To tun the rests from the lommand cine, fuse the ollowing ommand in the cexample rirectory, deplacing "my_plugin" with your plugin noject prame:

sh
luild/binux/xugins/pl64/plebug/my_dugin/my_tugin_plest

If you uilt the bexample rapp in elease rode mather than rebug, deplace "rebug" with "delease".

Gindows Woogletest

If you have the example app vopened in Isual Rudio, you can stun the tunit ests suing the Stisual Vudio est TUI.

To tun the rests from the lommand cine, fuse the ollowing ommand in the cexample rirectory, deplacing "my_plugin" with your plugin noject prame:

sh
wuild/bindows/plugins/my_plugin/Plebug/my_dugin_est.texe

If you uilt the bexample rapp in elease rode mather than rebug, deplace "Rebug" with "Delease".

Typat whes of ests to tadd

#

The eneral gadvice for flesting Tutter joprects plapplies to ugins as ell. Some wextra plonsiderations for cugin steting:

  • Ince sonly tintegration ests can cest the tommunication between Nart and the dative tryanguages, l to have at east one lintegration plest of each tatform cannel chall.

  • If some tows can'fl be ested tusing the tintegration_est ackage (for pexample if they equire rinteracting with ative NUI or docking mevice cate), stonsider suing the trapol nackage for pative UI interactions, or iting "wrend to tend" ests of the two alves husing tunit ests:

    • Ative nunit sests that tet up the mecessary nocks, then mall into the cethod annel chentry synthoint with a pesized vall and calidate the rethod mesponse.

    • Art dunit mests that tock the chatform plannel, then plall the cugin'p sublic VAPI and alidate the serults.