You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@freemarker.apache.org by Woonsan Ko <wo...@apache.org> on 2015/10/11 04:56:34 UTC

Question on unit testing

Hi,

When I added a new unit test, `ant test' seems failing in many test
classes. e.g, FileTemplateLoaderTest, etc.
So, I had to change build.xml (in batchtest task) to include only my
new test class locally.
My dev env is Ant 1.9.6 (Ivy 2.4.0) and JDK 1.8 on OSX.
How can I run all the unit tests successfully?
Also, is there any tip to run single unit test in command line (like
`mvn test -Dtest=...')?

Thanks in advance,

Woonsan

Re: Question on unit testing

Posted by Daniel Dekany <dd...@freemail.hu>.
Just wanted to say that I will eventually get to this and the other
pull request. In days hopefully. And of course, thanks for your work!


Sunday, October 11, 2015, 5:35:20 PM, Woonsan Ko wrote:

> Hi Daniel,
>
> I figured out why the tests failed. HFS+ on OS X is not case-sensitive
> (but case-preserving) and the ast representation (on my env) seems to
> include newline literals ("\\r\\n"), but the expectation file contains
> only "\\n".
> Please see my comments in
> https://issues.apache.org/jira/browse/FREEMARKER-3 and review the PR.
>
> Thanks,
>
> Woonsan
>
>
> On Sun, Oct 11, 2015 at 8:57 PM, Woonsan Ko <wo...@apache.org> wrote:
>> On Sun, Oct 11, 2015 at 5:48 PM, Daniel Dekany <dd...@freemail.hu> wrote:
>>> Sunday, October 11, 2015, 4:56:34 AM, Woonsan Ko wrote:
>>>
>>>> Hi,
>>>>
>>>> When I added a new unit test, `ant test' seems failing in many test
>>>> classes. e.g, FileTemplateLoaderTest, etc.
>>>
>>> Maybe you ran into bugs in the test suite itself then. They are
>>> supposed to pass without doing anything special. I have only ever ran
>>> the test suite on Windows, and that's perhaps where the difference
>>> lies. They also must be all green if you ran them from Eclipse (or
>>> IntelliJ, etc.), and that's how I do it most of the time, since it's
>>> easier to navigate to errors, etc. You don't need the command line
>>> except for running JavaCC once (or after you have changed FTL.jj), and
>>> perhaps before a pull request to see if you have accidentally used a
>>> non-Java 5 API.
>>
>> I sometimes run unit test in IDE, but I also like running all the unit
>> tests in the command line. :-) That also helps continuous integration.
>> I didn't add any non-Java 5 compatible API usages in my PR. Also the
>> current ant build.xml enforces Java 1.5 in compile tasks already.
>>
>>>
>>> Anyway, can you look at the concrete errors to see if they are
>>> environment dependencies?
>>
>> Looks like environment related issue. When I run `ant test', it stops
>> after testing FileTemplateLoaderTest, and error is:
>>
>> junit.framework.AssertionFailedError
>>     at freemarker.cache.FileTemplateLoaderTest.testCaseSensitivity(FileTemplateLoaderTest.java:101)
>>
>> I'm not sure if OSX behaves like Windows somehow when resolving a file
>> or if this is something else yet.
>> I also tried it after excluding FileTemplateLoaderTest, but there are
>> other tests failing..
>> Anyway, I stopped there for now because this is not related to my pull
>> request. ;-) I'll look into the unit test issues later.
>>
>>>
>>>> So, I had to change build.xml (in batchtest task) to include only my
>>>> new test class locally.
>>>
>>> At least in Eclipse I can just right click on a package or class or
>>> method, and run it as JUnit test. (Then F11 to re-run it.)
>>>
>>>> My dev env is Ant 1.9.6 (Ivy 2.4.0) and JDK 1.8 on OSX.
>>>
>>> JDK 1.8 64 bit, 1.8.1, Windows 7 here... but if this matters, then
>>> that should be fixed.
>>>
>>>> How can I run all the unit tests successfully?
>>>> Also, is there any tip to run single unit test in command line (like
>>>> `mvn test -Dtest=...')?
>>>
>>> I think there was, but I don't remember the exact syntax anymore. But
>>> using you IDE is more efficient anyway.
>>
>> I'm used to Maven and Maven plugins for Eclipse, where I was able to
>> run unit test in IDE easily. Ant/Ivy/Eclipse environment looks a bit
>> different to me. I need some more time to learn.
>>
>> By the way, IIRC, you mentioned in old ML that it's planned to migrate
>> to Maven some day. Is it right? If so, when do you want to do that?
>>
>> Kind regards,
>>
>> Woonsan
>>
>>>
>>>> Thanks in advance,
>>>>
>>>> Woonsan
>>>>
>>>
>>> --
>>> Thanks,
>>>  Daniel Dekany
>>>
>

-- 
Thanks,
 Daniel Dekany


Re: Question on unit testing

Posted by Woonsan Ko <wo...@apache.org>.
Hi Daniel,

I figured out why the tests failed. HFS+ on OS X is not case-sensitive
(but case-preserving) and the ast representation (on my env) seems to
include newline literals ("\\r\\n"), but the expectation file contains
only "\\n".
Please see my comments in
https://issues.apache.org/jira/browse/FREEMARKER-3 and review the PR.

Thanks,

Woonsan


On Sun, Oct 11, 2015 at 8:57 PM, Woonsan Ko <wo...@apache.org> wrote:
> On Sun, Oct 11, 2015 at 5:48 PM, Daniel Dekany <dd...@freemail.hu> wrote:
>> Sunday, October 11, 2015, 4:56:34 AM, Woonsan Ko wrote:
>>
>>> Hi,
>>>
>>> When I added a new unit test, `ant test' seems failing in many test
>>> classes. e.g, FileTemplateLoaderTest, etc.
>>
>> Maybe you ran into bugs in the test suite itself then. They are
>> supposed to pass without doing anything special. I have only ever ran
>> the test suite on Windows, and that's perhaps where the difference
>> lies. They also must be all green if you ran them from Eclipse (or
>> IntelliJ, etc.), and that's how I do it most of the time, since it's
>> easier to navigate to errors, etc. You don't need the command line
>> except for running JavaCC once (or after you have changed FTL.jj), and
>> perhaps before a pull request to see if you have accidentally used a
>> non-Java 5 API.
>
> I sometimes run unit test in IDE, but I also like running all the unit
> tests in the command line. :-) That also helps continuous integration.
> I didn't add any non-Java 5 compatible API usages in my PR. Also the
> current ant build.xml enforces Java 1.5 in compile tasks already.
>
>>
>> Anyway, can you look at the concrete errors to see if they are
>> environment dependencies?
>
> Looks like environment related issue. When I run `ant test', it stops
> after testing FileTemplateLoaderTest, and error is:
>
> junit.framework.AssertionFailedError
>     at freemarker.cache.FileTemplateLoaderTest.testCaseSensitivity(FileTemplateLoaderTest.java:101)
>
> I'm not sure if OSX behaves like Windows somehow when resolving a file
> or if this is something else yet.
> I also tried it after excluding FileTemplateLoaderTest, but there are
> other tests failing..
> Anyway, I stopped there for now because this is not related to my pull
> request. ;-) I'll look into the unit test issues later.
>
>>
>>> So, I had to change build.xml (in batchtest task) to include only my
>>> new test class locally.
>>
>> At least in Eclipse I can just right click on a package or class or
>> method, and run it as JUnit test. (Then F11 to re-run it.)
>>
>>> My dev env is Ant 1.9.6 (Ivy 2.4.0) and JDK 1.8 on OSX.
>>
>> JDK 1.8 64 bit, 1.8.1, Windows 7 here... but if this matters, then
>> that should be fixed.
>>
>>> How can I run all the unit tests successfully?
>>> Also, is there any tip to run single unit test in command line (like
>>> `mvn test -Dtest=...')?
>>
>> I think there was, but I don't remember the exact syntax anymore. But
>> using you IDE is more efficient anyway.
>
> I'm used to Maven and Maven plugins for Eclipse, where I was able to
> run unit test in IDE easily. Ant/Ivy/Eclipse environment looks a bit
> different to me. I need some more time to learn.
>
> By the way, IIRC, you mentioned in old ML that it's planned to migrate
> to Maven some day. Is it right? If so, when do you want to do that?
>
> Kind regards,
>
> Woonsan
>
>>
>>> Thanks in advance,
>>>
>>> Woonsan
>>>
>>
>> --
>> Thanks,
>>  Daniel Dekany
>>

Re: Question on unit testing

Posted by Daniel Baktiar <db...@gmail.com>.
Hi Daniel,

Do you think migrating to Maven is the way to go?

Regards,
Daniel Baktiar (oops, sorry another Daniel here)

On Sat, Oct 31, 2015 at 12:02 AM Daniel Dekany <dd...@freemail.hu> wrote:

> It would be in fact very good news if this thing can go with Maven...
> looking forward for the results!
>
>
> Thursday, October 29, 2015, 10:54:50 AM, Woonsan Ko wrote:
>
> >>> By the way, IIRC, you mentioned in old ML that it's planned to migrate
> >>> to Maven some day. Is it right? If so, when do you want to do that?
> >>
> >> I'm not sure if that would work out well, given that FM needs to be
> >> compiled against multiple versions of the same library (including
> >> rt.jar). But if someone works this topic out, it might turns out that
> >> it's feasible after all. I don't know. But the bet is on Gradle. And
> >> that will probably only happen when someone other than me takes that
> >> task.
> >
> > I think it should be possible with Maven (e.g, by using multiple
> > activatable profiles and system dependencies). I'd like to experiment
> > it in a branch. Will let you know if I make some progress. :-)
> >
> > Cheers,
> >
> > Woonsan
> >
>
> --
> Thanks,
>  Daniel Dekany
>
>

Re: Question on unit testing

Posted by Daniel Dekany <dd...@freemail.hu>.
It would be in fact very good news if this thing can go with Maven...
looking forward for the results!


Thursday, October 29, 2015, 10:54:50 AM, Woonsan Ko wrote:

>>> By the way, IIRC, you mentioned in old ML that it's planned to migrate
>>> to Maven some day. Is it right? If so, when do you want to do that?
>>
>> I'm not sure if that would work out well, given that FM needs to be
>> compiled against multiple versions of the same library (including
>> rt.jar). But if someone works this topic out, it might turns out that
>> it's feasible after all. I don't know. But the bet is on Gradle. And
>> that will probably only happen when someone other than me takes that
>> task.
>
> I think it should be possible with Maven (e.g, by using multiple
> activatable profiles and system dependencies). I'd like to experiment
> it in a branch. Will let you know if I make some progress. :-)
>
> Cheers,
>
> Woonsan
>

-- 
Thanks,
 Daniel Dekany


Re: Question on unit testing

Posted by Woonsan Ko <wo...@apache.org>.
>> By the way, IIRC, you mentioned in old ML that it's planned to migrate
>> to Maven some day. Is it right? If so, when do you want to do that?
>
> I'm not sure if that would work out well, given that FM needs to be
> compiled against multiple versions of the same library (including
> rt.jar). But if someone works this topic out, it might turns out that
> it's feasible after all. I don't know. But the bet is on Gradle. And
> that will probably only happen when someone other than me takes that
> task.

I think it should be possible with Maven (e.g, by using multiple
activatable profiles and system dependencies). I'd like to experiment
it in a branch. Will let you know if I make some progress. :-)

Cheers,

Woonsan

Re: Question on unit testing

Posted by Daniel Dekany <dd...@freemail.hu>.
Sunday, October 11, 2015, 1:57:53 PM, Woonsan Ko wrote:

[snip]
> junit.framework.AssertionFailedError
>     at
> freemarker.cache.FileTemplateLoaderTest.testCaseSensitivity(FileTemplateLoaderTest.java:101)
>
> I'm not sure if OSX behaves like Windows somehow when resolving a file

It's case sensitive AFAIK, while Windows isn't.

> or if this is something else yet.
> I also tried it after excluding FileTemplateLoaderTest, but there are
> other tests failing..
> Anyway, I stopped there for now because this is not related to my pull
> request. ;-) I'll look into the unit test issues later.
>
>>
>>> So, I had to change build.xml (in batchtest task) to include only my
>>> new test class locally.
>>
>> At least in Eclipse I can just right click on a package or class or
>> method, and run it as JUnit test. (Then F11 to re-run it.)
>>
>>> My dev env is Ant 1.9.6 (Ivy 2.4.0) and JDK 1.8 on OSX.
>>
>> JDK 1.8 64 bit, 1.8.1, Windows 7 here... but if this matters, then
>> that should be fixed.
>>
>>> How can I run all the unit tests successfully?
>>> Also, is there any tip to run single unit test in command line (like
>>> `mvn test -Dtest=...')?
>>
>> I think there was, but I don't remember the exact syntax anymore. But
>> using you IDE is more efficient anyway.
>
> I'm used to Maven and Maven plugins for Eclipse, where I was able to
> run unit test in IDE easily. Ant/Ivy/Eclipse environment looks a bit
> different to me. I need some more time to learn.

No plugin is needed. Just right click, and Run as JUnit test.

> By the way, IIRC, you mentioned in old ML that it's planned to migrate
> to Maven some day. Is it right? If so, when do you want to do that?

I'm not sure if that would work out well, given that FM needs to be
compiled against multiple versions of the same library (including
rt.jar). But if someone works this topic out, it might turns out that
it's feasible after all. I don't know. But the bet is on Gradle. And
that will probably only happen when someone other than me takes that
task.

> Kind regards,
>
> Woonsan
>
>>
>>> Thanks in advance,
>>>
>>> Woonsan
>>>
>>
>> --
>> Thanks,
>>  Daniel Dekany
>>
>

-- 
Thanks,
 Daniel Dekany


Re: Question on unit testing

Posted by Woonsan Ko <wo...@apache.org>.
On Sun, Oct 11, 2015 at 5:48 PM, Daniel Dekany <dd...@freemail.hu> wrote:
> Sunday, October 11, 2015, 4:56:34 AM, Woonsan Ko wrote:
>
>> Hi,
>>
>> When I added a new unit test, `ant test' seems failing in many test
>> classes. e.g, FileTemplateLoaderTest, etc.
>
> Maybe you ran into bugs in the test suite itself then. They are
> supposed to pass without doing anything special. I have only ever ran
> the test suite on Windows, and that's perhaps where the difference
> lies. They also must be all green if you ran them from Eclipse (or
> IntelliJ, etc.), and that's how I do it most of the time, since it's
> easier to navigate to errors, etc. You don't need the command line
> except for running JavaCC once (or after you have changed FTL.jj), and
> perhaps before a pull request to see if you have accidentally used a
> non-Java 5 API.

I sometimes run unit test in IDE, but I also like running all the unit
tests in the command line. :-) That also helps continuous integration.
I didn't add any non-Java 5 compatible API usages in my PR. Also the
current ant build.xml enforces Java 1.5 in compile tasks already.

>
> Anyway, can you look at the concrete errors to see if they are
> environment dependencies?

Looks like environment related issue. When I run `ant test', it stops
after testing FileTemplateLoaderTest, and error is:

junit.framework.AssertionFailedError
    at freemarker.cache.FileTemplateLoaderTest.testCaseSensitivity(FileTemplateLoaderTest.java:101)

I'm not sure if OSX behaves like Windows somehow when resolving a file
or if this is something else yet.
I also tried it after excluding FileTemplateLoaderTest, but there are
other tests failing..
Anyway, I stopped there for now because this is not related to my pull
request. ;-) I'll look into the unit test issues later.

>
>> So, I had to change build.xml (in batchtest task) to include only my
>> new test class locally.
>
> At least in Eclipse I can just right click on a package or class or
> method, and run it as JUnit test. (Then F11 to re-run it.)
>
>> My dev env is Ant 1.9.6 (Ivy 2.4.0) and JDK 1.8 on OSX.
>
> JDK 1.8 64 bit, 1.8.1, Windows 7 here... but if this matters, then
> that should be fixed.
>
>> How can I run all the unit tests successfully?
>> Also, is there any tip to run single unit test in command line (like
>> `mvn test -Dtest=...')?
>
> I think there was, but I don't remember the exact syntax anymore. But
> using you IDE is more efficient anyway.

I'm used to Maven and Maven plugins for Eclipse, where I was able to
run unit test in IDE easily. Ant/Ivy/Eclipse environment looks a bit
different to me. I need some more time to learn.

By the way, IIRC, you mentioned in old ML that it's planned to migrate
to Maven some day. Is it right? If so, when do you want to do that?

Kind regards,

Woonsan

>
>> Thanks in advance,
>>
>> Woonsan
>>
>
> --
> Thanks,
>  Daniel Dekany
>

Re: Question on unit testing

Posted by Daniel Dekany <dd...@freemail.hu>.
Sunday, October 11, 2015, 4:56:34 AM, Woonsan Ko wrote:

> Hi,
>
> When I added a new unit test, `ant test' seems failing in many test
> classes. e.g, FileTemplateLoaderTest, etc.

Maybe you ran into bugs in the test suite itself then. They are
supposed to pass without doing anything special. I have only ever ran
the test suite on Windows, and that's perhaps where the difference
lies. They also must be all green if you ran them from Eclipse (or
IntelliJ, etc.), and that's how I do it most of the time, since it's
easier to navigate to errors, etc. You don't need the command line
except for running JavaCC once (or after you have changed FTL.jj), and
perhaps before a pull request to see if you have accidentally used a
non-Java 5 API.

Anyway, can you look at the concrete errors to see if they are
environment dependencies?

> So, I had to change build.xml (in batchtest task) to include only my
> new test class locally.

At least in Eclipse I can just right click on a package or class or
method, and run it as JUnit test. (Then F11 to re-run it.)

> My dev env is Ant 1.9.6 (Ivy 2.4.0) and JDK 1.8 on OSX.

JDK 1.8 64 bit, 1.8.1, Windows 7 here... but if this matters, then
that should be fixed.

> How can I run all the unit tests successfully?
> Also, is there any tip to run single unit test in command line (like
> `mvn test -Dtest=...')?

I think there was, but I don't remember the exact syntax anymore. But
using you IDE is more efficient anyway.

> Thanks in advance,
>
> Woonsan
>

-- 
Thanks,
 Daniel Dekany