Printing a message for passed tests.

2,564 views
Skip to first unread message

sushantra mahapat

unread,
Sep 22, 2011, 1:03:58 PM9/22/11
to testng...@googlegroups.com
Hi ,
i am running  a parameterised tests to test some urls.
for failed url's i could print the message in the report it self , but for passed tests i am not not able to show the message even though i have a message in the
assert .
 
since all tests have the same name , i couldn't make out which url's passed.
 
Thanks,
 

martino

unread,
Sep 22, 2011, 1:10:07 PM9/22/11
to testng-users
Well 2 options:

Easy one: use try catch for ur assert and print the message in the
report
Other one: override the assert to print in to the report in bath cases

Cheers,
Martino

On Sep 22, 7:03 pm, sushantra mahapat <sushantkuma...@gmail.com>
wrote:

skm

unread,
Sep 23, 2011, 12:13:33 PM9/23/11
to testng-users
Hi ,
the First option i have already tried and that's not working.

2nd one i am not sure , appreciate if you could share some examples .

Jason McSwain

unread,
Sep 23, 2011, 2:51:13 PM9/23/11
to testng...@googlegroups.com
I'm a little confused on your question:

the text in an "assert"  like:

AssertJUnit.assertEquals("my message that will help me determine whey there was a failure here", expectedValue, actualValue);

this message isn't relevant when a test passes.

What you really want to do is generate unique test names for all tests, so that you can see each iteration of the test's context.  If this is what you are actually looking for, then please refer to section "5.5.3 - Parameters in reports"  of the documentation.  http://testng.org/doc/documentation-main.html#parameters-reports

I hope this helps,
-Jason-


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

Krishnan Mahadevan

unread,
Sep 23, 2011, 11:51:47 PM9/23/11
to testng...@googlegroups.com
Perhaps you could take the TestNG Listener route, and then take care of this logging for every PASSED tests, because in your LISTENERS you would have access to all tests along with their execution status.


Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"



skm

unread,
Sep 25, 2011, 12:04:23 AM9/25/11
to testng-users
Hi Jason,
yes your understanding of my problem is correct , earlier i alos
tried using params through data provided
But the problem is only the parameter type is getting displayed not
the actual value. i wanto to see the actual value.

Example :

Name Started
Duration Exception
**************************************************************************************************
Method1() 16:40:29 5
ms Method Failed for Value -1 (Failed
Method)
Method2() 16:40:39 3
ms
(Passed Method)


My problem is , some how i want to show a message for a passed test
(Method2) to know which value has passed and i have almost >1k values
to test.

Thanks.

On Sep 23, 11:51 pm, Jason McSwain <jasonwmcsw...@gmail.com> wrote:
> I'm a little confused on your question:
>
> the text in an "assert"  like:
>
> AssertJUnit.assertEquals("my message that will help me determine whey there
> was a failure here", expectedValue, actualValue);
>
> this message isn't relevant when a test passes.
>
> What you really want to do is generate unique test names for all tests, so
> that you can see each iteration of the test's context.  If this is what you
> are actually looking for, then please refer to section "5.5.3 - Parameters
> in reports"  of the documentation.http://testng.org/doc/documentation-main.html#parameters-reports
>
> I hope this helps,
> -Jason-*
>
> *
> On Thu, Sep 22, 2011 at 12:03 PM, sushantra mahapat <
>
>
>
> sushantkuma...@gmail.com> wrote:
> > Hi ,
> > i am running  a parameterised tests to test some urls.
> > for failed url's i could print the message in the report it self , but for
> > passed tests i am not not able to show the message even though i have a
> > message in the
> > assert .
>
> > since all tests have the same name , i couldn't make out which url's
> > passed.
>
> > Thanks,
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "testng-users" group.
> > To post to this group, send email to testng...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > testng-users...@googlegroups.com.
> > For more options, visit this group at
> >http://groups.google.com/group/testng-users?hl=en.- Hide quoted text -
>
> - Show quoted text -

santosh h s

unread,
Sep 27, 2011, 9:53:03 AM9/27/11
to testng...@googlegroups.com
Hi All,
i tried printing the message by using the below syntax but i do not see any message in results html file
 assertTrue("my message goes here",selenium.isElementPresent("emailAddress"));
please let me know how to do this
--

/Santosh

Cédric Beust ♔

unread,
Sep 27, 2011, 10:25:36 AM9/27/11
to testng...@googlegroups.com
This message is only printed if the assertion fails. Please read the related documentation.

-- 
Cédric

santosh h s

unread,
Sep 28, 2011, 12:37:04 PM9/28/11
to testng...@googlegroups.com
how to print message even if the  assertion passes

2011/9/27 Cédric Beust ♔ <ced...@beust.com>



--

/Santosh

martino turturiello

unread,
Sep 28, 2011, 12:40:37 PM9/28/11
to testng...@googlegroups.com
Hi
something like this....


....
try{
            Assert.assertTrue(condition);
            Report.log("your message");
    }
catch (AssertError ae)
{
          Report.log("ae");
          throw ae;
}



Is not the best way.. but is easy!


;-)

2011/9/28 santosh h s <santos...@gmail.com>



--
-----------------------------------------------------
Chi non ha apprezzato il suo maestro né la sua lezione, un giorno sarà forse colto, ma non sarà mai saggio.


Numero telefonico 09711835500
Skype: turturiellomartino

P. Hill

unread,
Oct 5, 2011, 6:06:39 PM10/5/11
to testng...@googlegroups.com
I hope I didn't come into late on this discussion, but there seems to be an easy way to ID each test in a set of repeated tests.


On 9/24/2011 9:04 PM, skm wrote:

My problem is  , some how i want to show  a message for a passed test
(Method2) to know which value has passed and i have almost >1k values
to test.


Going back to the original problem,
>since all tests have the same name , i couldn't make out which url's passed.
and
>But the problem is only the parameter type is getting displayed not the actual value. i want to to see the actual value.

If you want a long series of repeats of the same test but with different parameters to each identifying themselves with a more readable name of your choosing which reflects the input data then you need not play with Report objects you only need to change the information listed by default.

I think your problem would be solved by putting one or more of parameters you need per test into a wrapper object, then implement a toString() on this object which summarizes the information you would like to see in your report.  I have done this several times in the last month for data providers all containing 100s or 1000s of different values.  Make up whatever format you find useful for the report.  For example I have one test which uses a data provider which searches a directories tree for files and tests each one.  It would be hard to track unless I could see all the files it tried.

@Test
@DataProvider ...
public void checkSearching( SearchTest wrapper, Integer limitCount, ... ) {
}

class SearchTest {
   private String name;
   private int otherThing;
...
  public String toString() {
      return this.getClass().getSimpleName() + " { \"" + name + "\" }";
 }

For example scrapping (and editing a bit to match above) from one of the HTML reports from a successful test.
checkFileSearching
Test class: myStuff.SearchingTests
Parameters: SearchTest { "smallSet/Finds ABC" }, 30, ...

The string printed after Parameters in the standard report is simply the toString() of all parameters, the parameter you provided didn't have a toString() usable in a report.

HTH,
-Paul

Reply all
Reply to author
Forward
0 new messages