This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 253523 - TestCreatorProvider API/SPI difficult to use
Summary: TestCreatorProvider API/SPI difficult to use
Status: RESOLVED FIXED
Alias: None
Product: utilities
Classification: Unclassified
Component: Test Runner (show other bugs)
Version: 8.1
Hardware: All All
: P2 normal (vote)
Assignee: Theofanis Oikonomou
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-07-16 13:12 UTC by Tomas Mysik
Modified: 2015-08-21 01:20 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tomas Mysik 2015-07-16 13:12:33 UTC
For PHP, it is quite difficult to use the new TestCreatorProvider API/SPI. What is needed but currently not possible:

(1) PHPUnit constant is wrong, there are 4 different PHP testing providers in the build
--> I will change it to just "PHP"
(2) the lifecycle of the TestCreatorConfigurationProvider.getConfigurationPanel() is not clear - when exactly is it created? Displayed? Closed? For what project/file is it created? And how can I save any values if users click OK? IMHO there should be something like:

ConfigPanel createConfigPanel(Context, Project/FileObject) - not sure if Context is needed, do not get what it is good for

and ConfigPanel should have methods like:
void init() - called when displayed
void save() - called when OK button is clicked
void cancel() - called when Cancel button is clicked

(3) when is TestCreatorConfigurationProvider.getMessagePanel() called? What is its purpose?
(4) field "Class Name" does not make sense since not all PHP testing providers creates them. Ideally, allow to hide this field completely.

UI glitches:
(5) if dialog is resized, the components do not behave correctly

Thanks.
Comment 1 Tomas Mysik 2015-07-16 13:14:17 UTC
(In reply to Tomas Mysik from comment #0)
> (1) PHPUnit constant is wrong, there are 4 different PHP testing providers
> in the build
> --> I will change it to just "PHP"

BTW, when I changed the displayName in @Registration, the dialog was completely broken...
Comment 2 Theofanis Oikonomou 2015-07-17 13:22:37 UTC
(In reply to Tomas Mysik from comment #0)
> For PHP, it is quite difficult to use the new TestCreatorProvider API/SPI.
> What is needed but currently not possible:
> 
> (1) PHPUnit constant is wrong, there are 4 different PHP testing providers
> in the build
> --> I will change it to just "PHP"

I see the change in name. If I have at least one testing provider selected in project properties I also see a label notifying me what kind of test will be created. What do you mean by completely broken in comment 2?

> (2) the lifecycle of the
> TestCreatorConfigurationProvider.getConfigurationPanel() is not clear - when
> exactly is it created? Displayed? Closed? For what project/file is it
> created? And how can I save any values if users click OK? IMHO there should
> be something like:
> 
> ConfigPanel createConfigPanel(Context, Project/FileObject) - not sure if
> Context is needed, do not get what it is good for
> 
> and ConfigPanel should have methods like:
> void init() - called when displayed
> void save() - called when OK button is clicked
> void cancel() - called when Cancel button is clicked

I think you do not need to really care about these things as the lifecycle is supposed to be handled by org.netbeans.modules.gsf.testrunner.ui.CommonTestsCfgOfCreate class. You only need to implement 
TestCreatorConfigurationProvider. Specifically getConfigurationPanel, getSourceAndTestClassNames and getTestSourceRoots will be called when panel is displayed and persistConfigurationPanel will be called when user clicks OK button and you need to save any values. Does this make sense?

> 
> (3) when is TestCreatorConfigurationProvider.getMessagePanel() called? What
> is its purpose?

not called from anywhere. No purpose at this time. Should not be there at all.
messagePanel is used to display error messages related to test case name etc and has nothing to do with configuration panel.

> (4) field "Class Name" does not make sense since not all PHP testing
> providers creates them. Ideally, allow to hide this field completely.

will add the feature of hiding the field. By default it will be shown.

> 
> UI glitches:
> (5) if dialog is resized, the components do not behave correctly
> 
> Thanks.
Comment 3 Tomas Mysik 2015-07-17 13:42:21 UTC
(In reply to Theofanis Oikonomou from comment #2)
> What do you mean by completely broken in comment 2?

I changed "displayName" of the @Registration from PHP_UNIT constant to string "PHP" -> my provider was not in dialog. Apparently, it is more than just display name, right? ;)

> Does this make sense?

Maybe I am missing something but the provider is registered in the lookup, right? It means that it is a singleton. So, in such case, it should not have any internal state. How can I save the config panel if I don't have it? The persistConfigurationPanel() has only Context parameter, no panel anywhere. Please, do not tell me that I should remember it in some field, that is not the correct solution (but hack ;) althougth currently the only way how to do it, see PhpTestCreatorConfigurationProvider (I need a project for which getConfigurationPanel() method is called but I know nothing).

> not called from anywhere.

OK, I see.

> will add the feature of hiding the field. By default it will be shown.

Perfect, will work for me.

Thanks!
Comment 4 Theofanis Oikonomou 2015-07-17 14:21:57 UTC
Changeset: 2d262abe62eb
Author:    Theofanis Oikonomou <theofanis@netbeans.org>
Date:      2015-07-17 17:20
Message:   fixing point 4 from comment 1.
Comment 5 Theofanis Oikonomou 2015-07-17 14:23:11 UTC
closed it by accident...
Comment 6 Quality Engineering 2015-07-19 01:18:03 UTC
Integrated into 'main-silver', will be available in build *201507190001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/2d262abe62eb
User: Theofanis Oikonomou <theofanis@netbeans.org>
Log: fixing point 4 from comment 1.
Task #253523 - TestCreatorProvider API/SPI difficult to use
Comment 7 Tomas Mysik 2015-07-20 05:14:23 UTC
(In reply to Tomas Mysik from comment #3)
> Please, do not tell me that I should remember it in some field, that is not
> the correct solution (but hack ;) althougth currently the only way how to do
> it, see PhpTestCreatorConfigurationProvider (I need a project for which
> getConfigurationPanel() method is called but I know nothing).

OK, apparently this does not work reliably - see issue #253565.

Thanks.
Comment 8 Tomas Mysik 2015-07-20 07:40:48 UTC
(In reply to Quality Engineering from comment #6)
> Log: fixing point 4 from comment 1.

Again, showClassNameInfo() method does not take any parameter (FileObject or better Project) - _how_ can I return a correct value? What if we add a support for PHP testing framework which _can_ specify the target test class name? How can I, as a client of this API, decide for which project is my implemetation _currently_ called?

Thanks.
Comment 9 Tomas Mysik 2015-07-21 09:01:12 UTC
Just found out:

(6) Allow to hide also the source class name since it is optional as well (one can simply test just some function, not any class).

Thanks.
Comment 10 Theofanis Oikonomou 2015-07-23 14:30:52 UTC
Changeset: bb12f041683f
Author:    Theofanis Oikonomou <theofanis@netbeans.org>
Date:      2015-07-23 16:48
Message:
Comment 11 Theofanis Oikonomou 2015-07-23 15:00:48 UTC
Changeset: 98fcc8c86d4a
Author:    Theofanis Oikonomou <theofanis@netbeans.org>
Date:      2015-07-23 18:00
Message:   fix for comment 9
Comment 12 Theofanis Oikonomou 2015-07-23 15:02:59 UTC
Should be easier now :)
Comment 13 Quality Engineering 2015-07-24 01:17:58 UTC
Integrated into 'main-silver', will be available in build *201507240001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/bb12f041683f
User: Theofanis Oikonomou <theofanis@netbeans.org>
Log: Task #253523 - TestCreatorProvider API/SPI difficult to use
Comment 14 Theofanis Oikonomou 2015-07-24 14:10:05 UTC
Changeset: 292fd5cd05c5
Author:    Theofanis Oikonomou <theofanis@netbeans.org>
Date:      2015-07-24 14:49
Message:   introduce @Registration identifier in TestCreatorProvider
Comment 15 Quality Engineering 2015-07-25 01:16:24 UTC
Integrated into 'main-silver', will be available in build *201507250001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/292fd5cd05c5
User: Theofanis Oikonomou <theofanis@netbeans.org>
Log: introduce @Registration identifier in TestCreatorProvider
Task #253523 - TestCreatorProvider API/SPI difficult to use
Comment 16 Theofanis Oikonomou 2015-08-20 10:35:42 UTC
Changeset: ccbc5a52b796
Author:    Theofanis Oikonomou <theofanis@netbeans.org>
Date:      2015-08-20 13:33
Message:   added methods to check validity of configuration panel
Comment 17 Quality Engineering 2015-08-21 01:20:32 UTC
Integrated into 'main-silver', will be available in build *201508210002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/ccbc5a52b796
User: Theofanis Oikonomou <theofanis@netbeans.org>
Log: added methods to check validity of configuration panel
Task #253523 - TestCreatorProvider API/SPI difficult to use