Understanding assertEquals. Doesn't seem to work for me

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

Understanding assertEquals. Doesn't seem to work for me

Jim Engel
I am using the assertEquals method and I do not see the "Expected:" and "but was:" fields being filled in. As an example if I code assertEquals( "Something", "SomethingElse", "This test failed"); In the emailable-report.html I would have expected to see This test failed expected: SomethingElse but was: Something But what I see is This test failed expected: but was: The expected and actual never show up. If I code assertEquals( "Something", "1111", "This test failed"); I see This test failed expected:<1111> but was: Looks like string numbers works. What am I doing wrong? What do I need to do to get this to work? Thanks Jim Engel
Reply | Threaded
Open this post in threaded view
|

Re: Understanding assertEquals. Doesn't seem to work for me

Alexandru Popescu ☀

I have run the following test:

[code]
public class EmailableReportAssertionTest {
  @Test
  public void testngAsertion() {
    Assert.assertEquals(5, 6, "expected int inequality");
  }

  @Test
  public void jdkAssertion() {
    assert 5 == 6;
  }
}
[/code]

and I see in the emailable report:

Command line test
test.reports.EmailableReportAssertionTest:jdkAssertion

some expected assertion failure
test.reports.EmailableReportAssertionTest.jdkAssertion(EmailableReportAssertionTest.java:18)
22 lines not shown

test.reports.EmailableReportAssertionTest:testngAsertion

expected int inequality expected:<6> but was:<5>
org.testng.Assert.fail(Assert.java:84)
at org.testng.Assert.failNotEquals(Assert.java:438)
at org.testng.Assert.assertEquals(Assert.java:108)
at org.testng.Assert.assertEquals(Assert.java:323)
at test.reports.EmailableReportAssertionTest.testngAsertion(EmailableReportAssertionTest.java:13)
22 lines not shown

Looks pretty oke to me. By the way you are not mentioning what version
you are using.

./alex
--
.w( the_mindstorm )p.
  TestNG co-founder
EclipseTestNG Creator


On 2/8/07, Jim Engel <[hidden email]> wrote:

>  I am using the assertEquals method and I do not see the "Expected:" and
> "but was:" fields being filled in. As an example if I code assertEquals(
> "Something", "SomethingElse", "This test failed"); In the
> emailable-report.html I would have expected to see This test failed
> expected: SomethingElse but was: Something But what I see is This test
> failed expected: but was: The expected and actual never show up. If I code
> assertEquals( "Something", "1111", "This test failed"); I see This test
> failed expected:<1111> but was: Looks like string numbers works. What am I
> doing wrong? What do I need to do to get this to work? Thanks Jim Engel
> ________________________________
>  View this message in context: Understanding assertEquals. Doesn't seem to
> work for me
>  Sent from the testng-users mailing list archive at Nabble.com.
>
>  >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Understanding assertEquals. Doesn't seem to work for me

Jim Engel
Your test case uses ints. This also works for me.
It is strings that do not work.

I have figured out why. In the Assert class the format method
formats the message.  It encloses the text within <>.
When the email html is viewed with a web browser anything
with text between <> is treated as html and since the browser
does not under stand what is between<>, like <something>, it does not
get printed.
I modified the Assert class format method to enclose the text within ()
and the text then comes out.

I believe this is a bug.

     Thanks
         Jim Engel

P.S.  I forgot to mention I am using the 5.4 version
Reply | Threaded
Open this post in threaded view
|

Re: Understanding assertEquals. Doesn't seem to work for me

Steve Loughran-7

On 09/02/07, Jim Engel <[hidden email]> wrote:

>
>
> Your test case uses ints. This also works for me.
> It is strings that do not work.
>
> I have figured out why. In the Assert class the format method
> formats the message.  It encloses the text within <>.
> When the email html is viewed with a web browser anything
> with text between <> is treated as html and since the browser
> does not under stand what is between<>, like <something>, it does not
> get printed.
> I modified the Assert class format method to enclose the text within ()
> and the text then comes out.
>
> I believe this is a bug.

sounds like a bug in whatever generated your reports, not Assert
itself, that should not have to care about the output encoding.

what is generating your HTML emails? <junitreport>? Maven 2? some CI tool?

-steve

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Understanding assertEquals. Doesn't seem to work for me

Jim Engel
testng is generating the reports.
  jim

Steve Loughran-7 wrote
On 09/02/07, Jim Engel <jim.engel@verizon.net> wrote:
>
>
> Your test case uses ints. This also works for me.
> It is strings that do not work.
>
> I have figured out why. In the Assert class the format method
> formats the message.  It encloses the text within <>.
> When the email html is viewed with a web browser anything
> with text between <> is treated as html and since the browser
> does not under stand what is between<>, like <something>, it does not
> get printed.
> I modified the Assert class format method to enclose the text within ()
> and the text then comes out.
>
> I believe this is a bug.

sounds like a bug in whatever generated your reports, not Assert
itself, that should not have to care about the output encoding.

what is generating your HTML emails? <junitreport>? Maven 2? some CI tool?

-steve

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to testng-users@googlegroups.com
To unsubscribe from this group, send email to testng-users-unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en
-~----------~----~----~----~------~----~------~--~---
Reply | Threaded
Open this post in threaded view
|

Re: Understanding assertEquals. Doesn't seem to work for me

Steve Loughran-7

On 09/02/07, Jim Engel <[hidden email]> wrote:
>
>
> testng is generating the reports.

well, whatever generates the HTML has a bug.

FWIW if you go via <junitreport>  you will get all output escaped,
which is done as much for web site security as for ease of reading.
But if you somehow manage to get an angle bracket into the name of the
test, you'll find out that it, too, can get very confused.

-steve

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Understanding assertEquals. Doesn't seem to work for me

Alexandru Popescu ☀
In reply to this post by Jim Engel

On 2/9/07, Jim Engel <[hidden email]> wrote:
>
>
> testng is generating the reports.
>   jim
>

This looks like a bug, as the report would need to escape the output
HTML. I am gonna check it and fix it. Thanks for the report.

./alex
--
.w( the_mindstorm )p.
  TestNG co-founder
EclipseTestNG Creator



>
> Steve Loughran-7 wrote:
> >
> >
> > On 09/02/07, Jim Engel <[hidden email]> wrote:
> >>
> >>
> >> Your test case uses ints. This also works for me.
> >> It is strings that do not work.
> >>
> >> I have figured out why. In the Assert class the format method
> >> formats the message.  It encloses the text within <>.
> >> When the email html is viewed with a web browser anything
> >> with text between <> is treated as html and since the browser
> >> does not under stand what is between<>, like <something>, it does not
> >> get printed.
> >> I modified the Assert class format method to enclose the text within ()
> >> and the text then comes out.
> >>
> >> I believe this is a bug.
> >
> > sounds like a bug in whatever generated your reports, not Assert
> > itself, that should not have to care about the output encoding.
> >
> > what is generating your HTML emails? <junitreport>? Maven 2? some CI tool?
> >
> > -steve
> >
> > >
> >
> >
>
> --
> View this message in context: http://www.nabble.com/Understanding-assertEquals.-Doesn%27t-seem-to-work-for-me-tf3193906.html#a8885931
> Sent from the testng-users mailing list archive at Nabble.com.
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Understanding assertEquals. Doesn't seem to work for me

Alexandru Popescu ☀

Fixed in SVN trunk r.342.

./alex
--
.w( the_mindstorm )p.
  TestNG co-founder
EclipseTestNG Creator


On 2/9/07, Alexandru Popescu <[hidden email]> wrote:

> On 2/9/07, Jim Engel <[hidden email]> wrote:
> >
> >
> > testng is generating the reports.
> >   jim
> >
>
> This looks like a bug, as the report would need to escape the output
> HTML. I am gonna check it and fix it. Thanks for the report.
>
> ./alex
> --
> .w( the_mindstorm )p.
>   TestNG co-founder
> EclipseTestNG Creator
>
>
>
> >
> > Steve Loughran-7 wrote:
> > >
> > >
> > > On 09/02/07, Jim Engel <[hidden email]> wrote:
> > >>
> > >>
> > >> Your test case uses ints. This also works for me.
> > >> It is strings that do not work.
> > >>
> > >> I have figured out why. In the Assert class the format method
> > >> formats the message.  It encloses the text within <>.
> > >> When the email html is viewed with a web browser anything
> > >> with text between <> is treated as html and since the browser
> > >> does not under stand what is between<>, like <something>, it does not
> > >> get printed.
> > >> I modified the Assert class format method to enclose the text within ()
> > >> and the text then comes out.
> > >>
> > >> I believe this is a bug.
> > >
> > > sounds like a bug in whatever generated your reports, not Assert
> > > itself, that should not have to care about the output encoding.
> > >
> > > what is generating your HTML emails? <junitreport>? Maven 2? some CI tool?
> > >
> > > -steve
> > >
> > > >
> > >
> > >
> >
> > --
> > View this message in context: http://www.nabble.com/Understanding-assertEquals.-Doesn%27t-seem-to-work-for-me-tf3193906.html#a8885931
> > Sent from the testng-users mailing list archive at Nabble.com.
> >
> >
> > > >
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Understanding assertEquals. Doesn't seem to work

tarun3kumar

I built the latest code from SVN, but the emailable-report still is not escaping the < or > symbols in the test output.  Is this bug fixed for sure?  I set a reference to testng-5.6beta-jdk15.jar.  Thanks.
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.opensymphony.com/thread.jspa?threadID=63254&messageID=128122#128122


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Understanding assertEquals. Doesn't seem to work

Alexandru Popescu ☀

It should be fixed. Can you attach a test that reproduces the problem
you are seeing?

toodle-oo,

./alex
--
.w( the_mindstorm )p.
  TestNG co-founder
EclipseTestNG Creator


On 2/27/07, David Sousa <[hidden email]> wrote:
>
> I built the latest code from SVN, but the emailable-report still is not escaping the < or > symbols in the test output.  Is this bug fixed for sure?  I set a reference to testng-5.6beta-jdk15.jar.  Thanks.
> ---------------------------------------------------------------------
> Posted via Jive Forums
> http://forums.opensymphony.com/thread.jspa?threadID=63254&messageID=128122#128122
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Understanding assertEquals. Doesn't seem to work

tarun3kumar

It is fixed.  I got the latest again from SVN and built the dist-jar target.  The emailable report results are fine after adding the TestNG beta jar.  Thanks.
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.opensymphony.com/thread.jspa?threadID=63254&messageID=129749#129749


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Understanding assertEquals. Doesn't seem to work

tarun3kumar
In reply to this post by Alexandru Popescu ☀
I am sorry, but I spoke too soon.  The results display fine when using numbers.  However, string values do not work as expected.  I have attached an eclipse project that reproduces the problem.  I included the jar that I built as well as the emailable report.

I am using JDK 1.5 update 10 with eclipse 3.2 and viewing the report in IE 6.

Thanks,

Dave
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.opensymphony.com/thread.jspa?threadID=63254&messageID=129752#129752

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en
-~----------~----~----~----~------~----~------~--~---


TestReport.zip (1011K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Understanding assertEquals. Doesn't seem to work

Alexandru Popescu ☀

Are you running the test through the plugin? If so, have you
replaced/updated the TestNG jar available with the plugin to the one
you have built?

./alex
--
.w( the_mindstorm )p.
  TestNG co-founder
EclipseTestNG Creator


On 3/5/07, David Sousa <[hidden email]> wrote:

> I am sorry, but I spoke too soon.  The results display fine when using numbers.  However, string values do not work as expected.  I have attached an eclipse project that reproduces the problem.  I included the jar that I built as well as the emailable report.
>
> I am using JDK 1.5 update 10 with eclipse 3.2 and viewing the report in IE 6.
>
> Thanks,
>
> Dave
> ---------------------------------------------------------------------
> Posted via Jive Forums
> http://forums.opensymphony.com/thread.jspa?threadID=63254&messageID=129752#129752
>
> >
>
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Understanding assertEquals. Doesn't seem to work

tarun3kumar

I replaced the testng-jdk15.jar file in the plugin lib directory with the jar that I built.  That solved the problem.  Sorry for the newbie hassles.  Thanks.

Dave
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.opensymphony.com/thread.jspa?threadID=63254&messageID=129810#129810


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Understanding assertEquals. Doesn't seem to work

Alexandru Popescu ☀

On 3/5/07, David Sousa <[hidden email]> wrote:
>
> I replaced the testng-jdk15.jar file in the plugin lib directory with the jar that I built.  That solved the problem.  Sorry for the newbie hassles.  Thanks.
>

No problem. The most important thing is to have it working for you.

./alex
--
.w( the_mindstorm )p.
  TestNG co-founder
EclipseTestNG Creator

> Dave
> ---------------------------------------------------------------------
> Posted via Jive Forums
> http://forums.opensymphony.com/thread.jspa?threadID=63254&messageID=129810#129810
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en
-~----------~----~----~----~------~----~------~--~---