Difficulties getting control of TestNG after Reporter

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

Difficulties getting control of TestNG after Reporter

Jeff Russell-2

I am trying to perform some routine (like emailing) a file the reporter
generates.  The problem I have found is that I can not get control
after the Reporter runs.  I have tried annotations like @AfterClass and
@AfterGroups, but both of these seem to run before the reporter
generates its report files.

I am running the tests in Eclipse using the TestNG plugin.

Is there some method that can be used to get control after the Reporter
generates its reports?

Thanks.


--~--~---------~--~----~------------~-------~--~----~
 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: Difficulties getting control of TestNG after Reporter

Cédric Beust ♔
Hi Jeff,

Indeed, all the annotated methods need to have been invoked before the Reporter gets called.  That's by design.

I'm not quite sure what you're trying to achieve, but I can think of a couple of avenues to explore:
  • Create another Reporter (although there is no way to guarantee the order in which they are called right now, but this can be easily fixed).
  • Create a TestNG object yourself and run your code after its run() method returns.

--
Cedric



On 1/4/07, Jeff Russell <[hidden email]> wrote:

I am trying to perform some routine (like emailing) a file the reporter
generates.  The problem I have found is that I can not get control
after the Reporter runs.  I have tried annotations like @AfterClass and
@AfterGroups, but both of these seem to run before the reporter
generates its report files.

I am running the tests in Eclipse using the TestNG plugin.

Is there some method that can be used to get control after the Reporter
generates its reports?

Thanks.





--
Cédric
--~--~---------~--~----~------------~-------~--~----~
 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: Difficulties getting control of TestNG after Reporter

Jeff Russell-2

I have tried the second avenue - Creating a TestNG object myself and
after the run() method returns, I can then do what I want.  I ran into
a problem that I haven't fully explored... that is I have two tests.
One of the test I have purposly failed usng an assert(fail).  But the
reporter (and TestNG) are not seeing the test as a fail, but when it is
run from the TestNG plugin, it does fail.

The first avenue...
I'm fairly new to TestNG, so I'll have to look around at what you mean
by create another reporter.  If I were to do this, how/where would I
regain control?


On Jan 4, 4:20�pm, "C�dric Beust   " <[hidden email]> wrote:

> Hi Jeff,
>
> Indeed, all the annotated methods need to have been invoked before the
> Reporter gets called. �That's by design.
>
> I'm not quite sure what you're trying to achieve, but I can think of a
> couple of avenues to explore:
>
> � �- Create another Reporter (although there is no way to guarantee the
> � �order in which they are called right now, but this can be easily fixed).
> � �- Create a TestNG object yourself and run your code after its run()
> � �method returns.
>
> --
> Cedric
>
> On 1/4/07, Jeff Russell <[hidden email]> wrote:
>
>
>
>
>
>
>
> > I am trying to perform some routine (like emailing) a file the reporter
> > generates. �The problem I have found is that I can not get control
> > after the Reporter runs. �I have tried annotations like @AfterClass and
> > @AfterGroups, but both of these seem to run before the reporter
> > generates its report files.
>
> > I am running the tests in Eclipse using the TestNG plugin.
>
> > Is there some method that can be used to get control after the Reporter
> > generates its reports?
>
> > Thanks.--
> C�dric- Hide quoted text -- Show quoted text -


--~--~---------~--~----~------------~-------~--~----~
 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: Difficulties getting control of TestNG after Reporter

Cédric Beust ♔
Jeff,

Let's explore the first approach.

A typical way to use your own runner is as follows:

TestNG tng = new TestNG();
tng.setTestClasses(new Class[] { ... });
TestListenerAdapter tla = new TestListenerAdapter();
tng.setListener(tla);
tng.run();

and then you'll find your results in tla.getPassedTests() and tla.getFailedTests().

If that's not what you're seeing, please give us more details...

--
Cedric


On 1/4/07, Jeff Russell <[hidden email]> wrote:

I have tried the second avenue - Creating a TestNG object myself and
after the run() method returns, I can then do what I want.  I ran into
a problem that I haven't fully explored... that is I have two tests.
One of the test I have purposly failed usng an assert(fail).  But the
reporter (and TestNG) are not seeing the test as a fail, but when it is
run from the TestNG plugin, it does fail.

The first avenue...
I'm fairly new to TestNG, so I'll have to look around at what you mean
by create another reporter.  If I were to do this, how/where would I
regain control?


On Jan 4, 4:20 pm, "C dric Beust   " < [hidden email]> wrote:

> Hi Jeff,
>
> Indeed, all the annotated methods need to have been invoked before the
> Reporter gets called. That's by design.
>
> I'm not quite sure what you're trying to achieve, but I can think of a
> couple of avenues to explore:
>
> - Create another Reporter (although there is no way to guarantee the
> order in which they are called right now, but this can be easily fixed).
> - Create a TestNG object yourself and run your code after its run()
> method returns.
>
> --
> Cedric
>
> On 1/4/07, Jeff Russell <[hidden email]> wrote:
>
>
>
>
>
>
>
> > I am trying to perform some routine (like emailing) a file the reporter
> > generates. The problem I have found is that I can not get control
> > after the Reporter runs. I have tried annotations like @AfterClass and
> > @AfterGroups, but both of these seem to run before the reporter
> > generates its report files.
>
> > I am running the tests in Eclipse using the TestNG plugin.
>
> > Is there some method that can be used to get control after the Reporter
> > generates its reports?
>
> > Thanks.--
> C dric- Hide quoted text -- Show quoted text -







--
C dric
--~--~---------~--~----~------------~-------~--~----~
 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: Difficulties getting control of TestNG after Reporter

Jeff Russell-2

I still see both of my tests pass.  The tests are very simple.
public class notThrough {

        @Test(groups = { "goodTest" })
        public void aGoodTest() {
                System.out.println("This Test will PASS.");
                assert(true);
        }
        @Test(groups = { "badTest" })
        public void aBadTest() {
                System.out.println("This Test will fail.");
                assert(false);
        }
}

And I have these print commands after the tng.run() comand
        System.out.println("Passed Tests");
        System.out.println(tla.getPassedTests());
        System.out.println("Failed Tests");
        System.out.println(tla.getFailedTests());

When I run my little program, this is what I am seeing in the console:

[Parser] Running:
  Command line suite

This Test will PASS.
This Test will fail.

===============================================
Command line suite
Total tests run: 2, Failures: 0, Skips: 0
===============================================

Passed Tests
[[TestResult: aGoodTest STATUS:1 METHOD:notThrough.aGoodTest()],
[TestResult: aBadTest STATUS:1 METHOD:notThrough.aBadTest()]]
Failed Tests
[]

My Environment: Eclipse 3.2.1
TestNG Eclipse Support: 5.4.0.0
Libraries used in the project:
testng-jdk15.jar - C:\eclipse\plugins\org.testng.eclipse_5.4.0.0\lib
eclipse-testng.jar - C:\eclipse\plugins\orgi.testng.eclipse_5.4.0.0
JRE System Library [jre1.5.0_09]

On Jan 4, 5:11�pm, "C�dric Beust   " <[hidden email]> wrote:

> Jeff,
>
> Let's explore the first approach.
>
> A typical way to use your own runner is as follows:
>
> TestNG tng = new TestNG();
> tng.setTestClasses(new Class[] { ... });
> TestListenerAdapter tla = new TestListenerAdapter();
> tng.setListener(tla);
> tng.run();
>
> and then you'll find your results in tla.getPassedTests() and
> tla.getFailedTests().
>
> If that's not what you're seeing, please give us more details...
>
> --
> Cedric
>
> On 1/4/07, Jeff Russell <[hidden email]> wrote:
>
>
>
>
>
>
>
> > I have tried the second avenue - Creating a TestNG object myself and
> > after the run() method returns, I can then do what I want. �I ran into
> > a problem that I haven't fully explored... that is I have two tests.
> > One of the test I have purposly failed usng an assert(fail). �But the
> > reporter (and TestNG) are not seeing the test as a fail, but when it is
> > run from the TestNG plugin, it does fail.
>
> > The first avenue...
> > I'm fairly new to TestNG, so I'll have to look around at what you mean
> > by create another reporter. �If I were to do this, how/where would I
> > regain control?
>
> > On Jan 4, 4:20 pm, "C dric Beust � " <[hidden email]> wrote:
> > > Hi Jeff,
>
> > > Indeed, all the annotated methods need to have been invoked before the
> > > Reporter gets called. �That's by design.
>
> > > I'm not quite sure what you're trying to achieve, but I can think of a
> > > couple of avenues to explore:
>
> > > � �- Create another Reporter (although there is no way to guarantee the
> > > � �order in which they are called right now, but this can be easily
> > fixed).
> > > � �- Create a TestNG object yourself and run your code after its run()
> > > � �method returns.
>
> > > --
> > > Cedric
>
> > > On 1/4/07, Jeff Russell <[hidden email]> wrote:
>
> > > > I am trying to perform some routine (like emailing) a file the
> > reporter
> > > > generates. �The problem I have found is that I can not get control
> > > > after the Reporter runs. �I have tried annotations like @AfterClass
> > and
> > > > @AfterGroups, but both of these seem to run before the reporter
> > > > generates its report files.
>
> > > > I am running the tests in Eclipse using the TestNG plugin.
>
> > > > Is there some method that can be used to get control after the
> > Reporter
> > > > generates its reports?
>
> > > > Thanks.--
> > > C dric- Hide quoted text -- Show quoted text ---
> C ic- Hide quoted text -- Show quoted text -


--~--~---------~--~----~------------~-------~--~----~
 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: Difficulties getting control of TestNG after Reporter

Jeff Russell-2

I think I found the problem with this not failing.  by doing and
assert(), it was not causing the failure.  If I used the fail() method,
it did fail the test.  So now how do I get the reporter to generate all
of those wonderful html files after the test runs?

import org.testng.annotations.*;
import static org.testng.AssertJUnit.*;

public class notThrough {

        @Test(groups = { "goodTest" })
        public void aGoodTest() {
                System.out.println("This Test will PASS.");
                assert(true);
        }
        @Test(groups = { "badTest" })
        public void aBadTest() {
                System.out.println("This Test will fail.");
                assert(false);
                fail("This failes");
        }
}

On Jan 5, 9:27 am, "Jeff Russell" <[hidden email]> wrote:

> I still see both of my tests pass.  The tests are very simple.
> public class notThrough {
>
>         @Test(groups = { "goodTest" })
>         public void aGoodTest() {
>                 System.out.println("This Test will PASS.");
>                 assert(true);
>         }
>         @Test(groups = { "badTest" })
>         public void aBadTest() {
>                 System.out.println("This Test will fail.");
>                 assert(false);
>         }
>
> }And I have these print commands after the tng.run() comand
>         System.out.println("Passed Tests");
>         System.out.println(tla.getPassedTests());
>         System.out.println("Failed Tests");
>         System.out.println(tla.getFailedTests());
>
> When I run my little program, this is what I am seeing in the console:
>
> [Parser] Running:
>   Command line suite
>
> This Test will PASS.
> This Test will fail.
>
> ===============================================
> Command line suite
> Total tests run: 2, Failures: 0, Skips: 0
> ===============================================
>
> Passed Tests
> [[TestResult: aGoodTest STATUS:1 METHOD:notThrough.aGoodTest()],
> [TestResult: aBadTest STATUS:1 METHOD:notThrough.aBadTest()]]
> Failed Tests
> []
>
> My Environment: Eclipse 3.2.1
> TestNG Eclipse Support: 5.4.0.0
> Libraries used in the project:
> testng-jdk15.jar - C:\eclipse\plugins\org.testng.eclipse_5.4.0.0\lib
> eclipse-testng.jar - C:\eclipse\plugins\orgi.testng.eclipse_5.4.0.0
> JRE System Library [jre1.5.0_09]
>
> On Jan 4, 5:11 pm, "C�dric Beust   " <[hidden email]> wrote:
>
> > Jeff,
>
> > Let's explore the first approach.
>
> > A typical way to use your own runner is as follows:
>
> > TestNG tng = new TestNG();
> > tng.setTestClasses(new Class[] { ... });
> > TestListenerAdapter tla = new TestListenerAdapter();
> > tng.setListener(tla);
> > tng.run();
>
> > and then you'll find your results in tla.getPassedTests() and
> > tla.getFailedTests().
>
> > If that's not what you're seeing, please give us more details...
>
> > --
> > Cedric
>
> > On 1/4/07, Jeff Russell <[hidden email]> wrote:
>
> > > I have tried the second avenue - Creating a TestNG object myself and
> > > after the run() method returns, I can then do what I want.  I ran into
> > > a problem that I haven't fully explored... that is I have two tests.
> > > One of the test I have purposly failed usng an assert(fail).  But the
> > > reporter (and TestNG) are not seeing the test as a fail, but when it is
> > > run from the TestNG plugin, it does fail.
>
> > > The first avenue...
> > > I'm fairly new to TestNG, so I'll have to look around at what you mean
> > > by create another reporter.  If I were to do this, how/where would I
> > > regain control?
>
> > > On Jan 4, 4:20 pm, "C dric Beust   " <[hidden email]> wrote:
> > > > Hi Jeff,
>
> > > > Indeed, all the annotated methods need to have been invoked before the
> > > > Reporter gets called.  That's by design.
>
> > > > I'm not quite sure what you're trying to achieve, but I can think of a
> > > > couple of avenues to explore:
>
> > > >    - Create another Reporter (although there is no way to guarantee the
> > > >    order in which they are called right now, but this can be easily
> > > fixed).
> > > >    - Create a TestNG object yourself and run your code after its run()
> > > >    method returns.
>
> > > > --
> > > > Cedric
>
> > > > On 1/4/07, Jeff Russell <[hidden email]> wrote:
>
> > > > > I am trying to perform some routine (like emailing) a file the
> > > reporter
> > > > > generates.  The problem I have found is that I can not get control
> > > > > after the Reporter runs.  I have tried annotations like @AfterClass
> > > and
> > > > > @AfterGroups, but both of these seem to run before the reporter
> > > > > generates its report files.
>
> > > > > I am running the tests in Eclipse using the TestNG plugin.
>
> > > > > Is there some method that can be used to get control after the
> > > Reporter
> > > > > generates its reports?
>
> > > > > Thanks.--
> > > > C dric- Hide quoted text -- Show quoted text ---
> > C ic- Hide quoted text -- Show quoted text -


--~--~---------~--~----~------------~-------~--~----~
 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: Difficulties getting control of TestNG after Reporter

Cédric Beust ♔
In reply to this post by Jeff Russell-2
Can you try to throw an exception instead of "assert false"?  I'm suspecting you might not have -ea turned on...

--
Cedric


On 1/5/07, Jeff Russell <[hidden email]> wrote:

I still see both of my tests pass.  The tests are very simple.
public class notThrough {

        @Test(groups = { "goodTest" })
        public void aGoodTest() {
                System.out.println ("This Test will PASS.");
                assert(true);
        }
        @Test(groups = { "badTest" })
        public void aBadTest() {
                System.out.println("This Test will fail.");
                assert(false);
        }
}

And I have these print commands after the tng.run() comand
        System.out.println("Passed Tests");
        System.out.println(tla.getPassedTests ());
        System.out.println("Failed Tests");
        System.out.println(tla.getFailedTests());

When I run my little program, this is what I am seeing in the console:

[Parser] Running:
  Command line suite

This Test will PASS.
This Test will fail.

===============================================
Command line suite
Total tests run: 2, Failures: 0, Skips: 0
===============================================

Passed Tests
[[TestResult: aGoodTest STATUS:1 METHOD:notThrough.aGoodTest()],
[TestResult: aBadTest STATUS:1 METHOD:notThrough.aBadTest()]]
Failed Tests
[]

My Environment: Eclipse 3.2.1
TestNG Eclipse Support: 5.4.0.0
Libraries used in the project:
testng-jdk15.jar - C:\eclipse\plugins\org.testng.eclipse_5.4.0.0\lib
eclipse-testng.jar - C:\eclipse\plugins\orgi.testng.eclipse_5.4.0.0
JRE System Library [ jre1.5.0_09]

On Jan 4, 5:11 pm, "C dric Beust   " <[hidden email]> wrote:

> Jeff,
>
> Let's explore the first approach.
>
> A typical way to use your own runner is as follows:
>
> TestNG tng = new TestNG();
> tng.setTestClasses(new Class[] { ... });
> TestListenerAdapter tla = new TestListenerAdapter();
> tng.setListener(tla);
> tng.run();
>
> and then you'll find your results in tla.getPassedTests() and
> tla.getFailedTests().
>
> If that's not what you're seeing, please give us more details...
>
> --
> Cedric
>
> On 1/4/07, Jeff Russell < [hidden email]> wrote:
>
>
>
>
>
>
>
> > I have tried the second avenue - Creating a TestNG object myself and
> > after the run() method returns, I can then do what I want. I ran into
> > a problem that I haven't fully explored... that is I have two tests.
> > One of the test I have purposly failed usng an assert(fail). But the
> > reporter (and TestNG) are not seeing the test as a fail, but when it is
> > run from the TestNG plugin, it does fail.
>
> > The first avenue...
> > I'm fairly new to TestNG, so I'll have to look around at what you mean
> > by create another reporter. If I were to do this, how/where would I
> > regain control?
>
> > On Jan 4, 4:20 pm, "C dric Beust " <[hidden email]> wrote:
> > > Hi Jeff,
>
> > > Indeed, all the annotated methods need to have been invoked before the
> > > Reporter gets called. That's by design.
>
> > > I'm not quite sure what you're trying to achieve, but I can think of a
> > > couple of avenues to explore:
>
> > > - Create another Reporter (although there is no way to guarantee the
> > > order in which they are called right now, but this can be easily
> > fixed).
> > > - Create a TestNG object yourself and run your code after its run()
> > > method returns.
>
> > > --
> > > Cedric
>
> > > On 1/4/07, Jeff Russell <[hidden email]> wrote:
>
> > > > I am trying to perform some routine (like emailing) a file the
> > reporter
> > > > generates. The problem I have found is that I can not get control
> > > > after the Reporter runs. I have tried annotations like @AfterClass
> > and
> > > > @AfterGroups, but both of these seem to run before the reporter
> > > > generates its report files.
>
> > > > I am running the tests in Eclipse using the TestNG plugin.
>
> > > > Is there some method that can be used to get control after the
> > Reporter
> > > > generates its reports?
>
> > > > Thanks.--
> > > C dric- Hide quoted text -- Show quoted text ---
> C ic- Hide quoted text -- Show quoted text -







--
C dric
--~--~---------~--~----~------------~-------~--~----~
 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: Difficulties getting control of TestNG after Reporter

Cédric Beust ♔
In reply to this post by Jeff Russell-2
Ah, I should have read the entire thread before responding :-)

Glad we figured that part out.

On 1/5/07, Jeff Russell <[hidden email]> wrote:

I think I found the problem with this not failing.  by doing and
assert(), it was not causing the failure.  If I used the fail() method,
it did fail the test.  So now how do I get the reporter to generate all
of those wonderful html files after the test runs?

Not sure what you mean, are you saying you're not seeing any reports?

--
Cedric
 

import org.testng.annotations.*;
import static org.testng.AssertJUnit.*;

public class notThrough {

        @Test(groups = { "goodTest" })
        public void aGoodTest() {
                 System.out.println("This Test will PASS.");
                assert(true);
        }
        @Test(groups = { "badTest" })
        public void aBadTest() {
                System.out.println ("This Test will fail.");
                assert(false);
                fail("This failes");
        }
}

On Jan 5, 9:27 am, "Jeff Russell" <[hidden email]> wrote:

> I still see both of my tests pass.  The tests are very simple.
> public class notThrough {
>
>         @Test(groups = { "goodTest" })
>         public void aGoodTest() {
>                 System.out.println("This Test will PASS.");
>                 assert(true);
>         }
>         @Test(groups = { "badTest" })
>         public void aBadTest() {
>                 System.out.println("This Test will fail.");
>                 assert(false);
>         }
>
> }And I have these print commands after the tng.run() comand
>         System.out.println("Passed Tests");
>         System.out.println(tla.getPassedTests());
>         System.out.println("Failed Tests");
>         System.out.println(tla.getFailedTests());
>
> When I run my little program, this is what I am seeing in the console:
>
> [Parser] Running:
>   Command line suite
>
> This Test will PASS.
> This Test will fail.
>
> ===============================================
> Command line suite
> Total tests run: 2, Failures: 0, Skips: 0
> ===============================================
>
> Passed Tests
> [[TestResult: aGoodTest STATUS:1 METHOD:notThrough.aGoodTest()],
> [TestResult: aBadTest STATUS:1 METHOD:notThrough.aBadTest()]]
> Failed Tests
> []
>
> My Environment: Eclipse 3.2.1
> TestNG Eclipse Support: 5.4.0.0

> Libraries used in the project:
> testng-jdk15.jar - C:\eclipse\plugins\org.testng.eclipse_5.4.0.0\lib
> eclipse-testng.jar - C:\eclipse\plugins\orgi.testng.eclipse_5.4.0.0
> JRE System Library [jre1.5.0_09]
>
> On Jan 4, 5:11 pm, "C dric Beust   " <[hidden email]> wrote:
>
> > Jeff,
>
> > Let's explore the first approach.
>
> > A typical way to use your own runner is as follows:
>
> > TestNG tng = new TestNG();
> > tng.setTestClasses(new Class[] { ... });
> > TestListenerAdapter tla = new TestListenerAdapter();
> > tng.setListener(tla);
> > tng.run();
>
> > and then you'll find your results in tla.getPassedTests() and
> > tla.getFailedTests().
>
> > If that's not what you're seeing, please give us more details...
>
> > --
> > Cedric
>
> > On 1/4/07, Jeff Russell <[hidden email]> wrote:
>
> > > I have tried the second avenue - Creating a TestNG object myself and
> > > after the run() method returns, I can then do what I want.  I ran into
> > > a problem that I haven't fully explored... that is I have two tests.
> > > One of the test I have purposly failed usng an assert(fail).  But the
> > > reporter (and TestNG) are not seeing the test as a fail, but when it is
> > > run from the TestNG plugin, it does fail.
>
> > > The first avenue...
> > > I'm fairly new to TestNG, so I'll have to look around at what you mean
> > > by create another reporter.  If I were to do this, how/where would I
> > > regain control?
>
> > > On Jan 4, 4:20 pm, "C dric Beust   " <[hidden email]> wrote:
> > > > Hi Jeff,
>
> > > > Indeed, all the annotated methods need to have been invoked before the
> > > > Reporter gets called.  That's by design.
>
> > > > I'm not quite sure what you're trying to achieve, but I can think of a
> > > > couple of avenues to explore:
>
> > > >    - Create another Reporter (although there is no way to guarantee the
> > > >    order in which they are called right now, but this can be easily
> > > fixed).
> > > >    - Create a TestNG object yourself and run your code after its run()
> > > >    method returns.
>
> > > > --
> > > > Cedric
>
> > > > On 1/4/07, Jeff Russell <[hidden email]> wrote:
>
> > > > > I am trying to perform some routine (like emailing) a file the
> > > reporter
> > > > > generates.  The problem I have found is that I can not get control
> > > > > after the Reporter runs.  I have tried annotations like @AfterClass
> > > and

> > > > > @AfterGroups, but both of these seem to run before the reporter
> > > > > generates its report files.
>
> > > > > I am running the tests in Eclipse using the TestNG plugin.
>
> > > > > Is there some method that can be used to get control after the
> > > Reporter
> > > > > generates its reports?
>
> > > > > Thanks.--
> > > > C dric- Hide quoted text -- Show quoted text ---
> > C ic- Hide quoted text -- Show quoted text -







--
C dric
--~--~---------~--~----~------------~-------~--~----~
 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: Difficulties getting control of TestNG after Reporter

Jeff Russell-2

It seems that I missed the -ea switch.  If I set this, then yes, my
assert commads also fail.
Also if I set the verbose level to 10, then I get the html reports too.
 I think I'm all set.

Thanks very much for your help!!

On Jan 5, 10:44 am, "C�dric Beust   " <[hidden email]> wrote:

> Ah, I should have read the entire thread before responding :-)
>
> Glad we figured that part out.
>
> On 1/5/07, Jeff Russell <[hidden email]> wrote:
>
>
>
> > I think I found the problem with this not failing.  by doing and
> > assert(), it was not causing the failure.  If I used the fail() method,
> > it did fail the test.  So now how do I get the reporter to generate all
> > of those wonderful html files after the test runs?Not sure what you mean, are you saying you're not seeing any reports?
>
> --
> Cedric
>
> import org.testng.annotations.*;
>
>
>
> > import static org.testng.AssertJUnit.*;
>
> > public class notThrough {
>
> >         @Test(groups = { "goodTest" })
> >         public void aGoodTest() {
> >                 System.out.println("This Test will PASS.");
> >                 assert(true);
> >         }
> >         @Test(groups = { "badTest" })
> >         public void aBadTest() {
> >                 System.out.println("This Test will fail.");
> >                 assert(false);
> >                 fail("This failes");
> >         }
> > }
>
> > On Jan 5, 9:27 am, "Jeff Russell" <[hidden email]> wrote:
> > > I still see both of my tests pass.  The tests are very simple.
> > > public class notThrough {
>
> > >         @Test(groups = { "goodTest" })
> > >         public void aGoodTest() {
> > >                 System.out.println("This Test will PASS.");
> > >                 assert(true);
> > >         }
> > >         @Test(groups = { "badTest" })
> > >         public void aBadTest() {
> > >                 System.out.println("This Test will fail.");
> > >                 assert(false);
> > >         }
>
> > > }And I have these print commands after the tng.run() comand
> > >         System.out.println("Passed Tests");
> > >         System.out.println(tla.getPassedTests());
> > >         System.out.println("Failed Tests");
> > >         System.out.println(tla.getFailedTests());
>
> > > When I run my little program, this is what I am seeing in the console:
>
> > > [Parser] Running:
> > >   Command line suite
>
> > > This Test will PASS.
> > > This Test will fail.
>
> > > ===============================================
> > > Command line suite
> > > Total tests run: 2, Failures: 0, Skips: 0
> > > ===============================================
>
> > > Passed Tests
> > > [[TestResult: aGoodTest STATUS:1 METHOD:notThrough.aGoodTest()],
> > > [TestResult: aBadTest STATUS:1 METHOD:notThrough.aBadTest()]]
> > > Failed Tests
> > > []
>
> > > My Environment: Eclipse 3.2.1
> > > TestNG Eclipse Support: 5.4.0.0
> > > Libraries used in the project:
> > > testng-jdk15.jar - C:\eclipse\plugins\org.testng.eclipse_5.4.0.0\lib
> > > eclipse-testng.jar - C:\eclipse\plugins\orgi.testng.eclipse_5.4.0.0
> > > JRE System Library [jre1.5.0_09]
>
> > > On Jan 4, 5:11 pm, "C dric Beust   " <[hidden email]> wrote:
>
> > > > Jeff,
>
> > > > Let's explore the first approach.
>
> > > > A typical way to use your own runner is as follows:
>
> > > > TestNG tng = new TestNG();
> > > > tng.setTestClasses(new Class[] { ... });
> > > > TestListenerAdapter tla = new TestListenerAdapter();
> > > > tng.setListener(tla);
> > > > tng.run();
>
> > > > and then you'll find your results in tla.getPassedTests() and
> > > > tla.getFailedTests().
>
> > > > If that's not what you're seeing, please give us more details...
>
> > > > --
> > > > Cedric
>
> > > > On 1/4/07, Jeff Russell <[hidden email]> wrote:
>
> > > > > I have tried the second avenue - Creating a TestNG object myself and
> > > > > after the run() method returns, I can then do what I want.  I ran
> > into
> > > > > a problem that I haven't fully explored... that is I have two tests.
> > > > > One of the test I have purposly failed usng an assert(fail).  But
> > the
> > > > > reporter (and TestNG) are not seeing the test as a fail, but when it
> > is
> > > > > run from the TestNG plugin, it does fail.
>
> > > > > The first avenue...
> > > > > I'm fairly new to TestNG, so I'll have to look around at what you
> > mean
> > > > > by create another reporter.  If I were to do this, how/where would I
> > > > > regain control?
>
> > > > > On Jan 4, 4:20 pm, "C dric Beust   " <[hidden email]> wrote:
> > > > > > Hi Jeff,
>
> > > > > > Indeed, all the annotated methods need to have been invoked before
> > the
> > > > > > Reporter gets called.  That's by design.
>
> > > > > > I'm not quite sure what you're trying to achieve, but I can think
> > of a
> > > > > > couple of avenues to explore:
>
> > > > > >    - Create another Reporter (although there is no way to
> > guarantee the
> > > > > >    order in which they are called right now, but this can be
> > easily
> > > > > fixed).
> > > > > >    - Create a TestNG object yourself and run your code after its
> > run()
> > > > > >    method returns.
>
> > > > > > --
> > > > > > Cedric
>
> > > > > > On 1/4/07, Jeff Russell <[hidden email]> wrote:
>
> > > > > > > I am trying to perform some routine (like emailing) a file the
> > > > > reporter
> > > > > > > generates.  The problem I have found is that I can not get
> > control
> > > > > > > after the Reporter runs.  I have tried annotations like
> > @AfterClass
> > > > > and
> > > > > > > @AfterGroups, but both of these seem to run before the reporter
> > > > > > > generates its report files.
>
> > > > > > > I am running the tests in Eclipse using the TestNG plugin.
>
> > > > > > > Is there some method that can be used to get control after the
> > > > > Reporter
> > > > > > > generates its reports?
>
> > > > > > > Thanks.--
> > > > > > C dric- Hide quoted text -- Show quoted text ---
> > > > C ic- Hide quoted text -- Show quoted text ---
> C dric


--~--~---------~--~----~------------~-------~--~----~
 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: Difficulties getting control of TestNG after Reporter

Cédric Beust ♔
Jeff,

You shouldn't have to set the verbosity level to 10 to get the reports...  Can you give more details about what's happening exactly? 

--
Cedric

On 1/5/07, Jeff Russell <[hidden email]> wrote:

It seems that I missed the -ea switch.  If I set this, then yes, my
assert commads also fail.
Also if I set the verbose level to 10, then I get the html reports too.
I think I'm all set.

Thanks very much for your help!!

On Jan 5, 10:44 am, "C dric Beust   " <[hidden email]> wrote:

> Ah, I should have read the entire thread before responding :-)
>
> Glad we figured that part out.
>
> On 1/5/07, Jeff Russell <[hidden email]> wrote:
>
>
>
> > I think I found the problem with this not failing.  by doing and
> > assert(), it was not causing the failure.  If I used the fail() method,
> > it did fail the test.  So now how do I get the reporter to generate all
> > of those wonderful html files after the test runs?Not sure what you mean, are you saying you're not seeing any reports?
>
> --
> Cedric
>
> import org.testng.annotations.*;
>
>
>
> > import static org.testng.AssertJUnit.*;
>
> > public class notThrough {
>
> >         @Test(groups = { "goodTest" })
> >         public void aGoodTest() {
> >                 System.out.println("This Test will PASS.");
> >                 assert(true);
> >         }
> >         @Test(groups = { "badTest" })
> >         public void aBadTest() {
> >                 System.out.println("This Test will fail.");
> >                 assert(false);
> >                 fail("This failes");
> >         }
> > }
>
> > On Jan 5, 9:27 am, "Jeff Russell" <[hidden email]> wrote:
> > > I still see both of my tests pass.  The tests are very simple.
> > > public class notThrough {
>
> > >         @Test(groups = { "goodTest" })
> > >         public void aGoodTest() {
> > >                 System.out.println ("This Test will PASS.");
> > >                 assert(true);
> > >         }
> > >         @Test(groups = { "badTest" })
> > >         public void aBadTest() {
> > >                 System.out.println("This Test will fail.");
> > >                 assert(false);
> > >         }
>
> > > }And I have these print commands after the tng.run() comand
> > >         System.out.println("Passed Tests");
> > >         System.out.println(tla.getPassedTests());
> > >         System.out.println("Failed Tests");
> > >         System.out.println(tla.getFailedTests());
>
> > > When I run my little program, this is what I am seeing in the console:
>
> > > [Parser] Running:
> > >   Command line suite
>
> > > This Test will PASS.
> > > This Test will fail.
>
> > > ===============================================
> > > Command line suite
> > > Total tests run: 2, Failures: 0, Skips: 0
> > > ===============================================
>
> > > Passed Tests
> > > [[TestResult: aGoodTest STATUS:1 METHOD:notThrough.aGoodTest()],
> > > [TestResult: aBadTest STATUS:1 METHOD: notThrough.aBadTest()]]
> > > Failed Tests
> > > []
>
> > > My Environment: Eclipse 3.2.1
> > > TestNG Eclipse Support: 5.4.0.0
> > > Libraries used in the project:
> > > testng-jdk15.jar - C:\eclipse\plugins\org.testng.eclipse_5.4.0.0\lib
> > > eclipse-testng.jar - C:\eclipse\plugins\orgi.testng.eclipse_5.4.0.0
> > > JRE System Library [jre1.5.0_09 ]
>
> > > On Jan 4, 5:11 pm, "C dric Beust   " <[hidden email]> wrote:
>
> > > > Jeff,
>
> > > > Let's explore the first approach.
>
> > > > A typical way to use your own runner is as follows:
>
> > > > TestNG tng = new TestNG();
> > > > tng.setTestClasses(new Class[] { ... });
> > > > TestListenerAdapter tla = new TestListenerAdapter();
> > > > tng.setListener(tla);
> > > > tng.run();
>
> > > > and then you'll find your results in tla.getPassedTests() and
> > > > tla.getFailedTests().
>
> > > > If that's not what you're seeing, please give us more details...
>
> > > > --
> > > > Cedric
>
> > > > On 1/4/07, Jeff Russell < [hidden email]> wrote:
>
> > > > > I have tried the second avenue - Creating a TestNG object myself and
> > > > > after the run() method returns, I can then do what I want.  I ran
> > into
> > > > > a problem that I haven't fully explored... that is I have two tests.
> > > > > One of the test I have purposly failed usng an assert(fail).  But
> > the
> > > > > reporter (and TestNG) are not seeing the test as a fail, but when it
> > is
> > > > > run from the TestNG plugin, it does fail.
>
> > > > > The first avenue...
> > > > > I'm fairly new to TestNG, so I'll have to look around at what you
> > mean
> > > > > by create another reporter.  If I were to do this, how/where would I
> > > > > regain control?

>
> > > > > On Jan 4, 4:20 pm, "C dric Beust   " <[hidden email]> wrote:
> > > > > > Hi Jeff,
>
> > > > > > Indeed, all the annotated methods need to have been invoked before
> > the
> > > > > > Reporter gets called.  That's by design.
>
> > > > > > I'm not quite sure what you're trying to achieve, but I can think
> > of a
> > > > > > couple of avenues to explore:
>
> > > > > >    - Create another Reporter (although there is no way to
> > guarantee the
> > > > > >    order in which they are called right now, but this can be
> > easily
> > > > > fixed).
> > > > > >    - Create a TestNG object yourself and run your code after its
> > run()
> > > > > >    method returns.
>
> > > > > > --
> > > > > > Cedric
>
> > > > > > On 1/4/07, Jeff Russell <[hidden email]> wrote:
>
> > > > > > > I am trying to perform some routine (like emailing) a file the
> > > > > reporter
> > > > > > > generates.  The problem I have found is that I can not get
> > control
> > > > > > > after the Reporter runs.  I have tried annotations like
> > @AfterClass
> > > > > and
> > > > > > > @AfterGroups, but both of these seem to run before the reporter
> > > > > > > generates its report files.
>
> > > > > > > I am running the tests in Eclipse using the TestNG plugin.
>
> > > > > > > Is there some method that can be used to get control after the
> > > > > Reporter
> > > > > > > generates its reports?
>
> > > > > > > Thanks.--
> > > > > > C dric- Hide quoted text -- Show quoted text ---
> > > > C ic- Hide quoted text -- Show quoted text ---
> C dric







--
C dric
--~--~---------~--~----~------------~-------~--~----~
 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: Difficulties getting control of TestNG after Reporter

Jeff Russell-2

My bad.  Upon further inspection it looks like the reports were getting
created.  I was used to seeing the information that they were being
created in the console.  But with the verbosity level set to its
default value, there was no indication on the console that the files
were being created.  When I looked at where the reports would be
created, they were there.


On Jan 5, 11:02 am, "C�dric Beust   " <[hidden email]> wrote:

> Jeff,
>
> You shouldn't have to set the verbosity level to 10 to get the reports...
> Can you give more details about what's happening exactly?
>
> --
> Cedric
>
> On 1/5/07, Jeff Russell <[hidden email]> wrote:
>
>
>
>
>
> > It seems that I missed the -ea switch.  If I set this, then yes, my
> > assert commads also fail.
> > Also if I set the verbose level to 10, then I get the html reports too.
> > I think I'm all set.
>
> > Thanks very much for your help!!
>
> > On Jan 5, 10:44 am, "C dric Beust   " <[hidden email]> wrote:
> > > Ah, I should have read the entire thread before responding :-)
>
> > > Glad we figured that part out.
>
> > > On 1/5/07, Jeff Russell <[hidden email]> wrote:
>
> > > > I think I found the problem with this not failing.  by doing and
> > > > assert(), it was not causing the failure.  If I used the fail()
> > method,
> > > > it did fail the test.  So now how do I get the reporter to generate
> > all
> > > > of those wonderful html files after the test runs?Not sure what you
> > mean, are you saying you're not seeing any reports?
>
> > > --
> > > Cedric
>
> > > import org.testng.annotations.*;
>
> > > > import static org.testng.AssertJUnit.*;
>
> > > > public class notThrough {
>
> > > >         @Test(groups = { "goodTest" })
> > > >         public void aGoodTest() {
> > > >                 System.out.println("This Test will PASS.");
> > > >                 assert(true);
> > > >         }
> > > >         @Test(groups = { "badTest" })
> > > >         public void aBadTest() {
> > > >                 System.out.println("This Test will fail.");
> > > >                 assert(false);
> > > >                 fail("This failes");
> > > >         }
> > > > }
>
> > > > On Jan 5, 9:27 am, "Jeff Russell" <[hidden email]> wrote:
> > > > > I still see both of my tests pass.  The tests are very simple.
> > > > > public class notThrough {
>
> > > > >         @Test(groups = { "goodTest" })
> > > > >         public void aGoodTest() {
> > > > >                 System.out.println("This Test will PASS.");
> > > > >                 assert(true);
> > > > >         }
> > > > >         @Test(groups = { "badTest" })
> > > > >         public void aBadTest() {
> > > > >                 System.out.println("This Test will fail.");
> > > > >                 assert(false);
> > > > >         }
>
> > > > > }And I have these print commands after the tng.run() comand
> > > > >         System.out.println("Passed Tests");
> > > > >         System.out.println(tla.getPassedTests());
> > > > >         System.out.println("Failed Tests");
> > > > >         System.out.println(tla.getFailedTests());
>
> > > > > When I run my little program, this is what I am seeing in the
> > console:
>
> > > > > [Parser] Running:
> > > > >   Command line suite
>
> > > > > This Test will PASS.
> > > > > This Test will fail.
>
> > > > > ===============================================
> > > > > Command line suite
> > > > > Total tests run: 2, Failures: 0, Skips: 0
> > > > > ===============================================
>
> > > > > Passed Tests
> > > > > [[TestResult: aGoodTest STATUS:1 METHOD:notThrough.aGoodTest()],
> > > > > [TestResult: aBadTest STATUS:1 METHOD:notThrough.aBadTest()]]
> > > > > Failed Tests
> > > > > []
>
> > > > > My Environment: Eclipse 3.2.1
> > > > > TestNG Eclipse Support: 5.4.0.0
> > > > > Libraries used in the project:
> > > > > testng-jdk15.jar - C:\eclipse\plugins\org.testng.eclipse_5.4.0.0\lib
> > > > > eclipse-testng.jar - C:\eclipse\plugins\orgi.testng.eclipse_5.4.0.0
> > > > > JRE System Library [jre1.5.0_09]
>
> > > > > On Jan 4, 5:11 pm, "C dric Beust   " <[hidden email]> wrote:
>
> > > > > > Jeff,
>
> > > > > > Let's explore the first approach.
>
> > > > > > A typical way to use your own runner is as follows:
>
> > > > > > TestNG tng = new TestNG();
> > > > > > tng.setTestClasses(new Class[] { ... });
> > > > > > TestListenerAdapter tla = new TestListenerAdapter();
> > > > > > tng.setListener(tla);
> > > > > > tng.run();
>
> > > > > > and then you'll find your results in tla.getPassedTests() and
> > > > > > tla.getFailedTests().
>
> > > > > > If that's not what you're seeing, please give us more details...
>
> > > > > > --
> > > > > > Cedric
>
> > > > > > On 1/4/07, Jeff Russell <[hidden email]> wrote:
>
> > > > > > > I have tried the second avenue - Creating a TestNG object myself
> > and
> > > > > > > after the run() method returns, I can then do what I want.  I
> > ran
> > > > into
> > > > > > > a problem that I haven't fully explored... that is I have two
> > tests.
> > > > > > > One of the test I have purposly failed usng an
> > assert(fail).  But
> > > > the
> > > > > > > reporter (and TestNG) are not seeing the test as a fail, but
> > when it
> > > > is
> > > > > > > run from the TestNG plugin, it does fail.
>
> > > > > > > The first avenue...
> > > > > > > I'm fairly new to TestNG, so I'll have to look around at what
> > you
> > > > mean
> > > > > > > by create another reporter.  If I were to do this, how/where
> > would I
> > > > > > > regain control?
>
> > > > > > > On Jan 4, 4:20 pm, "C dric Beust   " <[hidden email]> wrote:
> > > > > > > > Hi Jeff,
>
> > > > > > > > Indeed, all the annotated methods need to have been invoked
> > before
> > > > the
> > > > > > > > Reporter gets called.  That's by design.
>
> > > > > > > > I'm not quite sure what you're trying to achieve, but I can
> > think
> > > > of a
> > > > > > > > couple of avenues to explore:
>
> > > > > > > >    - Create another Reporter (although there is no way to
> > > > guarantee the
> > > > > > > >    order in which they are called right now, but this can be
> > > > easily
> > > > > > > fixed).
> > > > > > > >    - Create a TestNG object yourself and run your code after
> > its
> > > > run()
> > > > > > > >    method returns.
>
> > > > > > > > --
> > > > > > > > Cedric
>
> > > > > > > > On 1/4/07, Jeff Russell <[hidden email]> wrote:
>
> > > > > > > > > I am trying to perform some routine (like emailing) a file
> > the
> > > > > > > reporter
> > > > > > > > > generates.  The problem I have found is that I can not get
> > > > control
> > > > > > > > > after the Reporter runs.  I have tried annotations like
> > > > @AfterClass
> > > > > > > and
> > > > > > > > > @AfterGroups, but both of these seem to run before the
> > reporter
> > > > > > > > > generates its report files.
>
> > > > > > > > > I am running the tests in Eclipse using the TestNG plugin.
>
> > > > > > > > > Is there some method that can be used to get control after
> > the
> > > > > > > Reporter
> > > > > > > > > generates its reports?
>
> > > > > > > > > Thanks.--
> > > > > > > > C dric- Hide quoted text -- Show quoted text ---
> > > > > > C ic- Hide quoted text -- Show quoted text ---
> > > C dric--
> C dric


--~--~---------~--~----~------------~-------~--~----~
 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
-~----------~----~----~----~------~----~------~--~---