Ant JUnit tests

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Ant JUnit tests

Gintautas Grigelionis
I am refactoring Ant JUnit tests with a goal to make them more
"IDE-friendly". I found several tests that are implictly dependent on
ant.home property being set. In these cases, the test should be prevented
from execution by adding an assumption; however, perhaps there might be a
suitable default, like basedir + "/bootstrap" or some other location that
might be suggested in, say, javadoc?

Thanks, Gintas
Reply | Threaded
Open this post in threaded view
|

Re: Ant JUnit tests

Jaikiran Pai
Like discussed in the other thread, I don't understand what's wrong with
setting the expected properties in the IDE itself (like the "ant.home").
IDEs provide these configurations/settings for reasons like these. What
would it achieve by virtually disabling these tests, in IDE, by adding
those assumptions?

-Jaikiran


On 20/04/18 10:39 AM, Gintautas Grigelionis wrote:
> I am refactoring Ant JUnit tests with a goal to make them more
> "IDE-friendly". I found several tests that are implictly dependent on
> ant.home property being set. In these cases, the test should be prevented
> from execution by adding an assumption; however, perhaps there might be a
> suitable default, like basedir + "/bootstrap" or some other location that
> might be suggested in, say, javadoc?
>
> Thanks, Gintas
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Ant JUnit tests

Gintautas Grigelionis
Assumption is a "friendly reminder" -- the test is does not run unless the
assumption is valid; the assumption provides an explanation of what is
missing. My question was about how friendly we should be.

Gintas

2018-04-20 7:14 GMT+02:00 Jaikiran Pai <[hidden email]>:

> Like discussed in the other thread, I don't understand what's wrong with
> setting the expected properties in the IDE itself (like the "ant.home").
> IDEs provide these configurations/settings for reasons like these. What
> would it achieve by virtually disabling these tests, in IDE, by adding
> those assumptions?
>
> -Jaikiran
>
>
>
> On 20/04/18 10:39 AM, Gintautas Grigelionis wrote:
>
>> I am refactoring Ant JUnit tests with a goal to make them more
>> "IDE-friendly". I found several tests that are implictly dependent on
>> ant.home property being set. In these cases, the test should be prevented
>> from execution by adding an assumption; however, perhaps there might be a
>> suitable default, like basedir + "/bootstrap" or some other location that
>> might be suggested in, say, javadoc?
>>
>> Thanks, Gintas
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|

AW: Ant JUnit tests

Jan Matèrne (jhm)
Why not an assert with a meaningful message to test if the property is set?

Jan

> -----Ursprüngliche Nachricht-----
> Von: Gintautas Grigelionis [mailto:[hidden email]]
> Gesendet: Freitag, 20. April 2018 10:42
> An: Ant Developers List
> Betreff: Re: Ant JUnit tests
>
> Assumption is a "friendly reminder" -- the test is does not run unless
> the assumption is valid; the assumption provides an explanation of what
> is missing. My question was about how friendly we should be.
>
> Gintas
>
> 2018-04-20 7:14 GMT+02:00 Jaikiran Pai <[hidden email]>:
>
> > Like discussed in the other thread, I don't understand what's wrong
> > with setting the expected properties in the IDE itself (like the
> "ant.home").
> > IDEs provide these configurations/settings for reasons like these.
> > What would it achieve by virtually disabling these tests, in IDE, by
> > adding those assumptions?
> >
> > -Jaikiran
> >
> >
> >
> > On 20/04/18 10:39 AM, Gintautas Grigelionis wrote:
> >
> >> I am refactoring Ant JUnit tests with a goal to make them more
> >> "IDE-friendly". I found several tests that are implictly dependent
> on
> >> ant.home property being set. In these cases, the test should be
> >> prevented from execution by adding an assumption; however, perhaps
> >> there might be a suitable default, like basedir + "/bootstrap" or
> >> some other location that might be suggested in, say, javadoc?
> >>
> >> Thanks, Gintas
> >>
> >>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden email] For additional
> > commands, e-mail: [hidden email]
> >
> >


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Ant JUnit tests

Gintautas Grigelionis
That's what an assumption is for -- checking for preconditions.
Lack of preconditions does not mean the test should fail, it should not be
executed at all in order to avoid false negatives.
As I said, I will make assumptions explicit.
My question was, should I provide more information, like, what is the a
suitable value of ant.home?

Thanks, Gintas

2018-04-20 13:16 GMT+00:00 Jan Matèrne (jhm) <[hidden email]>:

> Why not an assert with a meaningful message to test if the property is set?
>
> Jan
>
> > -----Ursprüngliche Nachricht-----
> > Von: Gintautas Grigelionis [mailto:[hidden email]]
> > Gesendet: Freitag, 20. April 2018 10:42
> > An: Ant Developers List
> > Betreff: Re: Ant JUnit tests
> >
> > Assumption is a "friendly reminder" -- the test is does not run unless
> > the assumption is valid; the assumption provides an explanation of what
> > is missing. My question was about how friendly we should be.
> >
> > Gintas
> >
> > 2018-04-20 7:14 GMT+02:00 Jaikiran Pai <[hidden email]>:
> >
> > > Like discussed in the other thread, I don't understand what's wrong
> > > with setting the expected properties in the IDE itself (like the
> > "ant.home").
> > > IDEs provide these configurations/settings for reasons like these.
> > > What would it achieve by virtually disabling these tests, in IDE, by
> > > adding those assumptions?
> > >
> > > -Jaikiran
> > >
> > >
> > >
> > > On 20/04/18 10:39 AM, Gintautas Grigelionis wrote:
> > >
> > >> I am refactoring Ant JUnit tests with a goal to make them more
> > >> "IDE-friendly". I found several tests that are implictly dependent
> > on
> > >> ant.home property being set. In these cases, the test should be
> > >> prevented from execution by adding an assumption; however, perhaps
> > >> there might be a suitable default, like basedir + "/bootstrap" or
> > >> some other location that might be suggested in, say, javadoc?
> > >>
> > >> Thanks, Gintas
> > >>
> > >>
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: [hidden email] For additional
> > > commands, e-mail: [hidden email]
> > >
> > >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Ant JUnit tests

Nicolas Lalevée
In reply to this post by Gintautas Grigelionis


> Le 20 avr. 2018 à 07:09, Gintautas Grigelionis <[hidden email]> a écrit :
>
> I am refactoring Ant JUnit tests with a goal to make them more
> "IDE-friendly". I found several tests that are implictly dependent on
> ant.home property being set. In these cases, the test should be prevented
> from execution by adding an assumption; however, perhaps there might be a
> suitable default, like basedir + "/bootstrap" or some other location that
> might be suggested in, say, javadoc?

Rather than being skipped, it would prefer that such tests fail. I would assume that the test being skipped are only the tests that I cannot run, like the one testing a special feature of Windows while I am on MacOS. If it is just about an incorrect configuration of my IDE, I would want to be clearly notified that I can do something to run the tests, rather than silently skipping such tests. Because in the end I would want to run such tests.

Nicolas


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Ant JUnit tests

Gintautas Grigelionis
2018-04-20 15:26 GMT+00:00 Nicolas Lalevée <[hidden email]>:

> > Le 20 avr. 2018 à 07:09, Gintautas Grigelionis <[hidden email]>
> a écrit :
> >
> > I am refactoring Ant JUnit tests with a goal to make them more
> > "IDE-friendly". I found several tests that are implictly dependent on
> > ant.home property being set. In these cases, the test should be prevented
> > from execution by adding an assumption; however, perhaps there might be a
> > suitable default, like basedir + "/bootstrap" or some other location that
> > might be suggested in, say, javadoc?
>
> Rather than being skipped, it would prefer that such tests fail. I would
> assume that the test being skipped are only the tests that I cannot run,
> like the one testing a special feature of Windows while I am on MacOS. If
> it is just about an incorrect configuration of my IDE, I would want to be
> clearly notified that I can do something to run the tests, rather than
> silently skipping such tests. Because in the end I would want to run such
> tests.


I think I was clear that assumptions are not silent; here's an example of
assumptions from Ant build log

Testsuite: org.apache.tools.ant.util.JavaEnvUtilsTest
Tests run: 6, Failures: 0, Errors: 0, Skipped: 3, Time elapsed: 0,01 sec

Testcase: java10IsDetectedProperly(org.apache.tools.ant.util.JavaEnvUtilsTest):SKIPPED:
got: <false>, expected: is <true>
Testcase: testGetExecutableWindows(org.apache.tools.ant.util.JavaEnvUtilsTest):SKIPPED:
Test only runs on windows
Testcase: testGetExecutableNetware(org.apache.tools.ant.util.JavaEnvUtilsTest):SKIPPED:
Test only runs on netware

The first SKIPPED line is emitted by a messageless assumption

assumeTrue("10".equals(System.getProperty("java.specification.version")));

Now, I don't see a point why a system property "ant.home" should be treated
differently from a system property "java.specification.version". An
assumption should inform you that the test won't run unless the property is
set, and that's what you wanted: a notification that you can (and must) do
something to run the test.

Gintas
Reply | Threaded
Open this post in threaded view
|

Re: Ant JUnit tests

Nicolas Lalevée


> Le 20 avr. 2018 à 18:48, Gintautas Grigelionis <[hidden email]> a écrit :
>
> 2018-04-20 15:26 GMT+00:00 Nicolas Lalevée <[hidden email] <mailto:[hidden email]>>:
>
>>> Le 20 avr. 2018 à 07:09, Gintautas Grigelionis <[hidden email]>
>> a écrit :
>>>
>>> I am refactoring Ant JUnit tests with a goal to make them more
>>> "IDE-friendly". I found several tests that are implictly dependent on
>>> ant.home property being set. In these cases, the test should be prevented
>>> from execution by adding an assumption; however, perhaps there might be a
>>> suitable default, like basedir + "/bootstrap" or some other location that
>>> might be suggested in, say, javadoc?
>>
>> Rather than being skipped, it would prefer that such tests fail. I would
>> assume that the test being skipped are only the tests that I cannot run,
>> like the one testing a special feature of Windows while I am on MacOS. If
>> it is just about an incorrect configuration of my IDE, I would want to be
>> clearly notified that I can do something to run the tests, rather than
>> silently skipping such tests. Because in the end I would want to run such
>> tests.
>
>
> I think I was clear that assumptions are not silent; here's an example of
> assumptions from Ant build log
>
> Testsuite: org.apache.tools.ant.util.JavaEnvUtilsTest
> Tests run: 6, Failures: 0, Errors: 0, Skipped: 3, Time elapsed: 0,01 sec
>
> Testcase: java10IsDetectedProperly(org.apache.tools.ant.util.JavaEnvUtilsTest):SKIPPED:
> got: <false>, expected: is <true>
> Testcase: testGetExecutableWindows(org.apache.tools.ant.util.JavaEnvUtilsTest):SKIPPED:
> Test only runs on windows
> Testcase: testGetExecutableNetware(org.apache.tools.ant.util.JavaEnvUtilsTest):SKIPPED:
> Test only runs on netware
>
> The first SKIPPED line is emitted by a messageless assumption
>
> assumeTrue("10".equals(System.getProperty("java.specification.version")));
>
> Now, I don't see a point why a system property "ant.home" should be treated
> differently from a system property "java.specification.version ».

The property ‘ant.home’ is about how the test runner is setup, which is controlled by the end user.
The other one is about which jvm is running. The end user can certainly change it, but he is then shooting himself in the foot.

The ‘ant.home’ is not an unchangeable property like the jvm or the OS.

> An
> assumption should inform you that the test won't run unless the property is
> set, and that's what you wanted: a notification that you can (and must) do
> something to run the test.

I still need to make the distinction between the thing I cannot change to make the test pass, like the OS, and the things that I can and should fix in the config of my IDE.

Nicolas

Reply | Threaded
Open this post in threaded view
|

Re: Ant JUnit tests

Gintautas Grigelionis
2018-04-20 17:34 GMT+00:00 Nicolas Lalevée <[hidden email]>:

>
> > Le 20 avr. 2018 à 18:48, Gintautas Grigelionis <[hidden email]>
> a écrit :
> >
> > 2018-04-20 15:26 GMT+00:00 Nicolas Lalevée <[hidden email]
> <mailto:[hidden email]>>:
> >
> >>> Le 20 avr. 2018 à 07:09, Gintautas Grigelionis <
> [hidden email]> a écrit :
> >>>
> >>> I am refactoring Ant JUnit tests with a goal to make them more
> >>> "IDE-friendly". I found several tests that are implictly dependent on
> >>> ant.home property being set. In these cases, the test should be
> prevented
> >>> from execution by adding an assumption; however, perhaps there might
> be a
> >>> suitable default, like basedir + "/bootstrap" or some other location
> that
> >>> might be suggested in, say, javadoc?
> >>
> >> Rather than being skipped, it would prefer that such tests fail. I would
> >> assume that the test being skipped are only the tests that I cannot run,
> >> like the one testing a special feature of Windows while I am on MacOS.
> If
> >> it is just about an incorrect configuration of my IDE, I would want to
> be
> >> clearly notified that I can do something to run the tests, rather than
> >> silently skipping such tests. Because in the end I would want to run
> such
> >> tests.
> >
> >
> > I think I was clear that assumptions are not silent; here's an example of
> > assumptions from Ant build log
> >
> > Testsuite: org.apache.tools.ant.util.JavaEnvUtilsTest
> > Tests run: 6, Failures: 0, Errors: 0, Skipped: 3, Time elapsed: 0,01 sec
> >
> > Testcase: java10IsDetectedProperly(org.apache.tools.ant.util.
> JavaEnvUtilsTest):SKIPPED:
> > got: <false>, expected: is <true>
> > Testcase: testGetExecutableWindows(org.apache.tools.ant.util.
> JavaEnvUtilsTest):SKIPPED:
> > Test only runs on windows
> > Testcase: testGetExecutableNetware(org.apache.tools.ant.util.
> JavaEnvUtilsTest):SKIPPED:
> > Test only runs on netware
> >
> > The first SKIPPED line is emitted by a messageless assumption
> >
> > assumeTrue("10".equals(System.getProperty("java.
> specification.version")));
> >
> > Now, I don't see a point why a system property "ant.home" should be
> treated
> > differently from a system property "java.specification.version ».
>
> The property ‘ant.home’ is about how the test runner is setup, which is
> controlled by the end user.
> The other one is about which jvm is running. The end user can certainly
> change it, but he is then shooting himself in the foot.
>
> The ‘ant.home’ is not an unchangeable property like the jvm or the OS.
>
> > An
> > assumption should inform you that the test won't run unless the property
> is
> > set, and that's what you wanted: a notification that you can (and must)
> do
> > something to run the test.
>
> I still need to make the distinction between the thing I cannot change to
> make the test pass, like the OS, and the things that I can and should fix
> in the config of my IDE.


Fine, let's use assertions then. I suppose I should start with
ModifiedSelectorTest which currently uses assumptions.

Gintas