Loading ...
Sorry, an error occurred while loading the content.
 

Re: [junit] FW: junit@yahoogroups.com

Expand Messages
  • Dennis Lloyd Jr
    Hi Raghava, You might be interested in looking at some articles on pair-wise testing. Here is a link I found after a quick search on google that explains the
    Message 1 of 9 , Feb 29, 2008
      Hi Raghava,
      You might be interested in looking at some articles on pair-wise testing.
      Here is a link I found after a quick search on google that explains the
      concept: http://www.developsense.com/testing/PairwiseTesting.html
      There are tools out there that will generate the test cases for you using
      pair-wise techniques in a way that helps, in theory, find defects.
      Personally, I have not used these techniques extensively in my own practice,
      but it sounds like it might be useful in your problem.

      Depending on the parameters and the outputs, you may also want to look at
      boundary testing and input/output class testing as techniques.

      If the code already exists and you have access to it, another technique
      would to look at the control flow and write test cases that exercise each
      branch. The metric, "McCabe's Cyclomatic Complexity" would be useful for
      this as it will tell you how many paths are in a method. A tool such as Java
      Metrics can calculate this for you.

      Finally, if you haven't written the code yet, you may want to consider
      building the test cases and the code up in tandem. For example, write a
      small test case, and implement just enough code to make it pass. Then write
      another test case and a small amount of more code and so on. This way, every
      line of code you write will have coverage.

      Good luck,
      Dennis


      On 2/29/08, Kent Beck <kentb@...> wrote:
      >
      >
      >
      > _____
      >
      > From: Veera Raghav Reddy [mailto:veerapulagam@...<veerapulagam%40yahoo.com>]
      >
      > Sent: Friday, February 29, 2008 6:06 AM
      > To: kentb@... <kentb%40earthlink.net>
      > Subject: junit@yahoogroups.com <junit%40yahoogroups.com>
      >
      > Hi Kent,
      >
      > I am working as QA Engineer
      >
      > I have a requirement for API testing where we have many
      > APIs(Approaximately
      > 250),
      > each API method is going to take 3 to 10 parameters.
      >
      > If i have suppose 4 parameters in a method, the possible cases would be
      > Factorial(4)=24.
      > Is it advisable to prepare test scripts for all 24 methods(positive &
      > negative)?.
      >
      > Method 1:Writing test scripts for each case( positive or negative).ie 24
      > cases for a method which takes 4 parameters
      >
      > Method 2:Preparing common script for a method, using parser read
      > parameters
      > from an xml file and pass them to method
      >
      > Method 3:Preparing common script for a method, read parameters from txt
      > file
      > and pass them to method
      >
      > Note:I have the similar requirement in C# also
      >
      > It would be more appreciated if you suggest me the suitable way among the
      > above methods
      >
      > Thanks in advance...
      >
      > Regards,
      > Raghava
      >
      > _____
      >
      > Never miss a thing. Make Yahoo
      > <http://us.rd.yahoo.com/evt=51438/*http://www.yahoo.com/r/hs> your
      > homepage.
      >
      > [Non-text portions of this message have been removed]
      >
      >
      >


      [Non-text portions of this message have been removed]
    • Veera Raghav Reddy
      Hi Ilja, Thanks for your kind response... Here I am providing the sample test script that we are using, please suggest me the best way to test this kind of
      Message 2 of 9 , Mar 1, 2008
        Hi Ilja,

        Thanks for your kind response...


        Here I am providing the sample test script that we are using, please suggest me the best way to test this kind of requirement

        package net.project.tests.webservices.clients;

        import java.io.FileOutputStream;
        import junit.framework.*;

        import net.project.api.pep.*;
        import java.util.*;
        import java.util.ArrayList;
        import java.util.HashMap;
        import net.project.api.pap.role.*;
        import net.project.api.pap.application.*;
        import net.project.api.vo.ApplicationGroup;
        import net.project.api.vo.Application;
        import net.project.api.vo.Role;
        import net.project.api.vo.*;


        public class TestRoleAPI extends TestCase {

        private IRole mgr = null;
        FileOutputStream fos = null;
        public TestRoleAPI(String testName) {
        super(testName);
        try{
        fos = new FileOutputStream("../Java_PAPAPI_Report.txt",true);
        }catch(Exception ex){ex.printStackTrace();}
        }

        protected void setUp() throws java.lang.Exception {
        mgr=EntitlementManager.getInstance().getRoleManager();

        }

        protected void tearDown() throws java.lang.Exception {
        }

        /* public static junit.framework.Test suite() {
        junit.framework.TestSuite suite = new junit.framework.TestSuite(TestRoleAPI.class);
        return suite;
        }*/


        public void testAddDelegatedRoles() {

        try{
        //public void addDelegatedRoles(String delegatedRoles[],String delegateType, String applicationOrGroupName,HashMap map,String repositoryName) throws NoSuchRoleException, BaseException;
        String [] droles = {"PAP Application Group:PAP Application:guest"};

        Date d1 = new Date();
        HashMap h1 = new HashMap();
        h1.put("k1",d1);
        this.mgr.addDelegatedRoles(droles,"Application","Prime group:Prime portal",h1,"Default Domain");

        System.out.println("===================================");
        System.out.println("Test Succuss::AddDelegatedRoles");
        System.out.println("===================================");
        fos.write("Role_01 -- addDelegatedRoles() -- Success\r\n".getBytes());

        }catch(Exception ex)
        {
        try{
        fos.write("Role_01 -- addDelegatedRoles() -- Failure\r\n".getBytes());
        System.out.println("===================================");
        System.out.println("Test Failed:: AddDelegatedRoles ");
        fail("Test failed");
        System.out.println("===================================");
        }catch(Exception ex1){}
        }
        }



        }


        Thanks,
        Raghava

        Ilja Preuss <it@...> wrote: Hi Raghva,

        I'm not sure I understand the question.

        Can you show us an example method with 4 parameters, and explain,
        preferably with examples again, why you'd need 24 tests?

        Thanks,

        Ilja

        > I am working as QA Engineer
        >
        > I have a requirement for API testing where we have many APIs(Approaximately
        > 250),
        > each API method is going to take 3 to 10 parameters.
        >
        > If i have suppose 4 parameters in a method, the possible cases would be
        > Factorial(4)=24.
        > Is it advisable to prepare test scripts for all 24 methods(positive &
        > negative)?.
        >
        > Method 1:Writing test scripts for each case( positive or negative).ie 24
        > cases for a method which takes 4 parameters
        >
        > Method 2:Preparing common script for a method, using parser read parameters
        > from an xml file and pass them to method
        >
        > Method 3:Preparing common script for a method, read parameters from txt file
        > and pass them to method
        >
        > Note:I have the similar requirement in C# also
        >
        > It would be more appreciated if you suggest me the suitable way among the
        > above methods
        >
        > Thanks in advance...
        >
        > Regards,
        > Raghava
        >
        >
        > _____
        >
        > Never miss a thing. Make Yahoo
        > <http://us.rd.yahoo.com/evt=51438/*http://www.yahoo.com/r/hs> your homepage.
        >
        >
        >
        > [Non-text portions of this message have been removed]
        >
        >
        >
        >
        > Yahoo! Groups Links
        >
        >
        >
        >






        ---------------------------------
        Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now.

        [Non-text portions of this message have been removed]
      • Alexandru Popescu ☀
        ... Ilja, I think the original OP is thinking about all possible combination of input (positive/negative values). I am also thinking that he has left aside the
        Message 3 of 9 , Mar 1, 2008
          On Fri, Feb 29, 2008 at 11:05 PM, Ilja Preuss <it@...> wrote:
          >
          > Hi Raghva,
          >
          > I'm not sure I understand the question.
          >
          > Can you show us an example method with 4 parameters, and explain,
          > preferably with examples again, why you'd need 24 tests?
          >
          > Thanks,
          >
          > Ilja
          >

          Ilja, I think the original OP is thinking about all possible
          combination of input (positive/negative values).
          I am also thinking that he has left aside the exceptional behavioral
          testing and so.

          Now, in order to provoke the OP to provide more details I would say
          the following:

          1/ if you already have that data/real data available why not using it?
          2/ in case you don't have it and you should create it, then deciding
          about its format should be a matter of what that data represents and
          who is responsible in the real app to generate it. Is it enough for
          you to have the developers include it in the code directly? Would you
          like to be able to easily edit it on your QA team? Does that data need
          special formatting rules?

          (sorry for the small self/own project advertisement: I usually cover
          this topic in my testing presentations. Also I would mention that it
          is very well covered in the book Next Generation Java Testing and the
          scenario is very well supported in TestNG (http://testng.org), even if
          I am pretty sure JUnit has some mechanisms for it too).

          bests,

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

          >
          > > I am working as QA Engineer
          > >
          > > I have a requirement for API testing where we have many
          > APIs(Approaximately
          > > 250),
          > > each API method is going to take 3 to 10 parameters.
          > >
          > > If i have suppose 4 parameters in a method, the possible cases would be
          > > Factorial(4)=24.
          > > Is it advisable to prepare test scripts for all 24 methods(positive &
          > > negative)?.
          > >
          > > Method 1:Writing test scripts for each case( positive or negative).ie 24
          > > cases for a method which takes 4 parameters
          > >
          > > Method 2:Preparing common script for a method, using parser read
          > parameters
          > > from an xml file and pass them to method
          > >
          > > Method 3:Preparing common script for a method, read parameters from txt
          > file
          > > and pass them to method
          > >
          > > Note:I have the similar requirement in C# also
          > >
          > > It would be more appreciated if you suggest me the suitable way among the
          > > above methods
          > >
          > > Thanks in advance...
          > >
          > > Regards,
          > > Raghava
          > >
          > >
          > > _____
          > >
          > > Never miss a thing. Make Yahoo
          > > <http://us.rd.yahoo.com/evt=51438/*http://www.yahoo.com/r/hs> your
          > homepage.
          > >
          > >
          > >
          > > [Non-text portions of this message have been removed]
          > >
          > >
          > >
          > >
          > > Yahoo! Groups Links
          > >
          > >
          > >
          > >
          >
          >
        • Ilja Preuss
          First, you probably should get rid of a lot of the boiler plate code in your test. The catch block is not needed - just let the exception propagate, JUnit will
          Message 4 of 9 , Mar 2, 2008
            First, you probably should get rid of a lot of the boiler plate code in
            your test.

            The catch block is not needed - just let the exception propagate, JUnit
            will recognize this as a failed test.

            You shouldn't all those System.out statements. The JUnit runner should
            you provide with enough info (use a different one if it doesn't).

            And for the reporting, use either your own implementation of a
            TestListener (I think that's the current API?), or use for example the
            Ant task(s).

            Then your tests look like this:


            > protected void setUp() throws java.lang.Exception {
            > mgr=EntitlementManager.getInstance().getRoleManager();
            > }
            >
            > public void testAddDelegatedRoles() {
            > String [] droles = {"PAP Application Group:PAP
            Application:guest"};
            > Date d1 = new Date();
            > HashMap h1 = new HashMap();
            > h1.put("k1",d1);
            > this.mgr.addDelegatedRoles(droles,"Application","Prime
            group:Prime portal",h1,"Default Domain");
            > }
            >
            > }

            So what this probably should test is the addDelegateRoles method, which
            takes 5 parameters. What is missing, though, is some kind of assertion
            that the method did what it should do. What should that method do?

            Cheers, Ilja

            Veera Raghav Reddy wrote:
            > Hi Ilja,
            >
            > Thanks for your kind response...
            >
            >
            > Here I am providing the sample test script that we are using, please suggest me the best way to test this kind of requirement
            >
            > package net.project.tests.webservices.clients;
            >
            > import java.io.FileOutputStream;
            > import junit.framework.*;
            >
            > import net.project.api.pep.*;
            > import java.util.*;
            > import java.util.ArrayList;
            > import java.util.HashMap;
            > import net.project.api.pap.role.*;
            > import net.project.api.pap.application.*;
            > import net.project.api.vo.ApplicationGroup;
            > import net.project.api.vo.Application;
            > import net.project.api.vo.Role;
            > import net.project.api.vo.*;
            >
            >
            > public class TestRoleAPI extends TestCase {
            >
            > private IRole mgr = null;
            > FileOutputStream fos = null;
            > public TestRoleAPI(String testName) {
            > super(testName);
            > try{
            > fos = new FileOutputStream("../Java_PAPAPI_Report.txt",true);
            > }catch(Exception ex){ex.printStackTrace();}
            > }
            >
            > protected void setUp() throws java.lang.Exception {
            > mgr=EntitlementManager.getInstance().getRoleManager();
            >
            > }
            >
            > protected void tearDown() throws java.lang.Exception {
            > }
            >
            > /* public static junit.framework.Test suite() {
            > junit.framework.TestSuite suite = new junit.framework.TestSuite(TestRoleAPI.class);
            > return suite;
            > }*/
            >
            >
            > public void testAddDelegatedRoles() {
            >
            > try{
            > //public void addDelegatedRoles(String delegatedRoles[],String delegateType, String applicationOrGroupName,HashMap map,String repositoryName) throws NoSuchRoleException, BaseException;
            > String [] droles = {"PAP Application Group:PAP Application:guest"};
            >
            > Date d1 = new Date();
            > HashMap h1 = new HashMap();
            > h1.put("k1",d1);
            > this.mgr.addDelegatedRoles(droles,"Application","Prime group:Prime portal",h1,"Default Domain");
            >
            > System.out.println("===================================");
            > System.out.println("Test Succuss::AddDelegatedRoles");
            > System.out.println("===================================");
            > fos.write("Role_01 -- addDelegatedRoles() -- Success\r\n".getBytes());
            >
            > }catch(Exception ex)
            > {
            > try{
            > fos.write("Role_01 -- addDelegatedRoles() -- Failure\r\n".getBytes());
            > System.out.println("===================================");
            > System.out.println("Test Failed:: AddDelegatedRoles ");
            > fail("Test failed");
            > System.out.println("===================================");
            > }catch(Exception ex1){}
            > }
            > }
            >
            >
            >
            > }
            >
            >
            > Thanks,
            > Raghava
            >
            > Ilja Preuss <it@...> wrote: Hi Raghva,
            >
            > I'm not sure I understand the question.
            >
            > Can you show us an example method with 4 parameters, and explain,
            > preferably with examples again, why you'd need 24 tests?
            >
            > Thanks,
            >
            > Ilja
            >
            > > I am working as QA Engineer
            > >
            > > I have a requirement for API testing where we have many APIs(Approaximately
            > > 250),
            > > each API method is going to take 3 to 10 parameters.
            > >
            > > If i have suppose 4 parameters in a method, the possible cases would be
            > > Factorial(4)=24.
            > > Is it advisable to prepare test scripts for all 24 methods(positive &
            > > negative)?.
            > >
            > > Method 1:Writing test scripts for each case( positive or negative).ie 24
            > > cases for a method which takes 4 parameters
            > >
            > > Method 2:Preparing common script for a method, using parser read parameters
            > > from an xml file and pass them to method
            > >
            > > Method 3:Preparing common script for a method, read parameters from txt file
            > > and pass them to method
            > >
            > > Note:I have the similar requirement in C# also
            > >
            > > It would be more appreciated if you suggest me the suitable way among the
            > > above methods
            > >
            > > Thanks in advance...
            > >
            > > Regards,
            > > Raghava
            > >
            > >
            > > _____
            > >
            > > Never miss a thing. Make Yahoo
            > > <http://us.rd.yahoo.com/evt=51438/*http://www.yahoo.com/r/hs> your homepage.
            > >
            > >
            > >
            > > [Non-text portions of this message have been removed]
            > >
            > >
            > >
            > >
            > > Yahoo! Groups Links
            > >
            > >
            > >
            > >
            >
            >
            >
            >
            >
            >
            > ---------------------------------
            > Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now.
            >
            > [Non-text portions of this message have been removed]
            >
            >
            >
            >
            > Yahoo! Groups Links
            >
            >
            >
            >
          • Dennis Lloyd Jr
            Hi Raghava, It seems that your test case is just checking whether or not an exception is thrown. Typically when testing, you want to check the behavior of the
            Message 5 of 9 , Mar 2, 2008
              Hi Raghava,
              It seems that your test case is just checking whether or not an exception is
              thrown. Typically when testing, you want to check the behavior of the
              method. In other words, the method addDelegatedRoles does something. You
              should be testing that it did what was intended. It is rarely enough just to
              check that the method did not throw an exception.
              -Dennis

              On Sat, Mar 1, 2008 at 8:00 AM, Veera Raghav Reddy <veerapulagam@...>
              wrote:

              > Hi Ilja,
              >
              > Thanks for your kind response...
              >
              >
              > Here I am providing the sample test script that we are using, please
              > suggest me the best way to test this kind of requirement
              >
              > package net.project.tests.webservices.clients;
              >
              > import java.io.FileOutputStream;
              > import junit.framework.*;
              >
              > import net.project.api.pep.*;
              > import java.util.*;
              > import java.util.ArrayList;
              > import java.util.HashMap;
              > import net.project.api.pap.role.*;
              > import net.project.api.pap.application.*;
              > import net.project.api.vo.ApplicationGroup;
              > import net.project.api.vo.Application;
              > import net.project.api.vo.Role;
              > import net.project.api.vo.*;
              >
              >
              > public class TestRoleAPI extends TestCase {
              >
              > private IRole mgr = null;
              > FileOutputStream fos = null;
              > public TestRoleAPI(String testName) {
              > super(testName);
              > try{
              > fos = new FileOutputStream("../Java_PAPAPI_Report.txt",true);
              > }catch(Exception ex){ex.printStackTrace();}
              > }
              >
              > protected void setUp() throws java.lang.Exception {
              > mgr=EntitlementManager.getInstance().getRoleManager();
              >
              > }
              >
              > protected void tearDown() throws java.lang.Exception {
              > }
              >
              > /* public static junit.framework.Test suite() {
              > junit.framework.TestSuite suite = new junit.framework.TestSuite(
              > TestRoleAPI.class);
              > return suite;
              > }*/
              >
              >
              > public void testAddDelegatedRoles() {
              >
              > try{
              > //public void addDelegatedRoles(String delegatedRoles[],String
              > delegateType, String applicationOrGroupName,HashMap map,String
              > repositoryName) throws NoSuchRoleException, BaseException;
              > String [] droles = {"PAP Application Group:PAP Application:guest"};
              >
              > Date d1 = new Date();
              > HashMap h1 = new HashMap();
              > h1.put("k1",d1);
              > this.mgr.addDelegatedRoles(droles,"Application","Prime group:Prime
              > portal",h1,"Default Domain");
              >
              > System.out.println("===================================");
              > System.out.println("Test Succuss::AddDelegatedRoles");
              > System.out.println("===================================");
              > fos.write("Role_01 -- addDelegatedRoles() -- Success\r\n".getBytes());
              >
              > }catch(Exception ex)
              > {
              > try{
              > fos.write("Role_01 -- addDelegatedRoles() -- Failure\r\n".getBytes());
              > System.out.println("===================================");
              > System.out.println("Test Failed:: AddDelegatedRoles ");
              > fail("Test failed");
              > System.out.println("===================================");
              > }catch(Exception ex1){}
              > }
              > }
              >
              >
              >
              > }
              >
              >
              > Thanks,
              > Raghava
              >
              > Ilja Preuss <it@... <it%40iljapreuss.de>> wrote: Hi Raghva,
              >
              >
              > I'm not sure I understand the question.
              >
              > Can you show us an example method with 4 parameters, and explain,
              > preferably with examples again, why you'd need 24 tests?
              >
              > Thanks,
              >
              > Ilja
              >
              > > I am working as QA Engineer
              > >
              > > I have a requirement for API testing where we have many
              > APIs(Approaximately
              > > 250),
              > > each API method is going to take 3 to 10 parameters.
              > >
              > > If i have suppose 4 parameters in a method, the possible cases would be
              > > Factorial(4)=24.
              > > Is it advisable to prepare test scripts for all 24 methods(positive &
              > > negative)?.
              > >
              > > Method 1:Writing test scripts for each case( positive or negative).ie 24
              > > cases for a method which takes 4 parameters
              > >
              > > Method 2:Preparing common script for a method, using parser read
              > parameters
              > > from an xml file and pass them to method
              > >
              > > Method 3:Preparing common script for a method, read parameters from txt
              > file
              > > and pass them to method
              > >
              > > Note:I have the similar requirement in C# also
              > >
              > > It would be more appreciated if you suggest me the suitable way among
              > the
              > > above methods
              > >
              > > Thanks in advance...
              > >
              > > Regards,
              > > Raghava
              > >
              > >
              > > _____
              > >
              > > Never miss a thing. Make Yahoo
              > > <http://us.rd.yahoo.com/evt=51438/*http://www.yahoo.com/r/hs> your
              > homepage.
              > >
              > >
              > >
              > > [Non-text portions of this message have been removed]
              > >
              > >
              > >
              > >
              > > Yahoo! Groups Links
              > >
              > >
              > >
              > >
              >
              >
              >
              >
              >
              > ---------------------------------
              > Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it
              > now.
              >
              > [Non-text portions of this message have been removed]
              >
              >
              >


              [Non-text portions of this message have been removed]
            • Veera Raghav Reddy
              Hi Ilja, Thanks for your kind response. Shall I have to write same method once agian for different set of data(for negative cases) Please answer this query
              Message 6 of 9 , Mar 2, 2008
                Hi Ilja,

                Thanks for your kind response.

                Shall I have to write same method once agian for different set of data(for negative cases)

                Please answer this query

                Thanks,
                Raghava

                Ilja Preuss <it@...> wrote:
                First, you probably should get rid of a lot of the boiler plate code in
                your test.

                The catch block is not needed - just let the exception propagate, JUnit
                will recognize this as a failed test.

                You shouldn't all those System.out statements. The JUnit runner should
                you provide with enough info (use a different one if it doesn't).

                And for the reporting, use either your own implementation of a
                TestListener (I think that's the current API?), or use for example the
                Ant task(s).

                Then your tests look like this:

                > protected void setUp() throws java.lang.Exception {
                > mgr=EntitlementManager.getInstance().getRoleManager();
                > }
                >
                > public void testAddDelegatedRoles() {
                > String [] droles = {"PAP Application Group:PAP
                Application:guest"};
                > Date d1 = new Date();
                > HashMap h1 = new HashMap();
                > h1.put("k1",d1);
                > this.mgr.addDelegatedRoles(droles,"Application","Prime
                group:Prime portal",h1,"Default Domain");
                > }
                >
                > }

                So what this probably should test is the addDelegateRoles method, which
                takes 5 parameters. What is missing, though, is some kind of assertion
                that the method did what it should do. What should that method do?

                Cheers, Ilja

                Veera Raghav Reddy wrote:
                > Hi Ilja,
                >
                > Thanks for your kind response...
                >
                >
                > Here I am providing the sample test script that we are using, please suggest me the best way to test this kind of requirement
                >
                > package net.project.tests.webservices.clients;
                >
                > import java.io.FileOutputStream;
                > import junit.framework.*;
                >
                > import net.project.api.pep.*;
                > import java.util.*;
                > import java.util.ArrayList;
                > import java.util.HashMap;
                > import net.project.api.pap.role.*;
                > import net.project.api.pap.application.*;
                > import net.project.api.vo.ApplicationGroup;
                > import net.project.api.vo.Application;
                > import net.project.api.vo.Role;
                > import net.project.api.vo.*;
                >
                >
                > public class TestRoleAPI extends TestCase {
                >
                > private IRole mgr = null;
                > FileOutputStream fos = null;
                > public TestRoleAPI(String testName) {
                > super(testName);
                > try{
                > fos = new FileOutputStream("../Java_PAPAPI_Report.txt",true);
                > }catch(Exception ex){ex.printStackTrace();}
                > }
                >
                > protected void setUp() throws java.lang.Exception {
                > mgr=EntitlementManager.getInstance().getRoleManager();
                >
                > }
                >
                > protected void tearDown() throws java.lang.Exception {
                > }
                >
                > /* public static junit.framework.Test suite() {
                > junit.framework.TestSuite suite = new junit.framework.TestSuite(TestRoleAPI.class);
                > return suite;
                > }*/
                >
                >
                > public void testAddDelegatedRoles() {
                >
                > try{
                > //public void addDelegatedRoles(String delegatedRoles[],String delegateType, String applicationOrGroupName,HashMap map,String repositoryName) throws NoSuchRoleException, BaseException;
                > String [] droles = {"PAP Application Group:PAP Application:guest"};
                >
                > Date d1 = new Date();
                > HashMap h1 = new HashMap();
                > h1.put("k1",d1);
                > this.mgr.addDelegatedRoles(droles,"Application","Prime group:Prime portal",h1,"Default Domain");
                >
                > System.out.println("===================================");
                > System.out.println("Test Succuss::AddDelegatedRoles");
                > System.out.println("===================================");
                > fos.write("Role_01 -- addDelegatedRoles() -- Success\r\n".getBytes());
                >
                > }catch(Exception ex)
                > {
                > try{
                > fos.write("Role_01 -- addDelegatedRoles() -- Failure\r\n".getBytes());
                > System.out.println("===================================");
                > System.out.println("Test Failed:: AddDelegatedRoles ");
                > fail("Test failed");
                > System.out.println("===================================");
                > }catch(Exception ex1){}
                > }
                > }
                >
                >
                >
                > }
                >
                >
                > Thanks,
                > Raghava
                >
                > Ilja Preuss <it@...> wrote: Hi Raghva,
                >
                > I'm not sure I understand the question.
                >
                > Can you show us an example method with 4 parameters, and explain,
                > preferably with examples again, why you'd need 24 tests?
                >
                > Thanks,
                >
                > Ilja
                >
                > > I am working as QA Engineer
                > >
                > > I have a requirement for API testing where we have many APIs(Approaximately
                > > 250),
                > > each API method is going to take 3 to 10 parameters.
                > >
                > > If i have suppose 4 parameters in a method, the possible cases would be
                > > Factorial(4)=24.
                > > Is it advisable to prepare test scripts for all 24 methods(positive &
                > > negative)?.
                > >
                > > Method 1:Writing test scripts for each case( positive or negative).ie 24
                > > cases for a method which takes 4 parameters
                > >
                > > Method 2:Preparing common script for a method, using parser read parameters
                > > from an xml file and pass them to method
                > >
                > > Method 3:Preparing common script for a method, read parameters from txt file
                > > and pass them to method
                > >
                > > Note:I have the similar requirement in C# also
                > >
                > > It would be more appreciated if you suggest me the suitable way among the
                > > above methods
                > >
                > > Thanks in advance...
                > >
                > > Regards,
                > > Raghava
                > >
                > >
                > > _____
                > >
                > > Never miss a thing. Make Yahoo
                > > <http://us.rd.yahoo.com/evt=51438/*http://www.yahoo.com/r/hs> your homepage.
                > >
                > >
                > >
                > > [Non-text portions of this message have been removed]
                > >
                > >
                > >
                > >
                > > Yahoo! Groups Links
                > >
                > >
                > >
                > >
                >
                >
                >
                >
                >
                >
                > ---------------------------------
                > Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now.
                >
                > [Non-text portions of this message have been removed]
                >
                >
                >
                >
                > Yahoo! Groups Links
                >
                >
                >
                >






                ---------------------------------
                Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now.

                [Non-text portions of this message have been removed]
              • toalexsmail
                Hello Ilja! First of all I want to answer on your direct question - yes you should write different method for negative case because its code is completely
                Message 7 of 9 , Mar 12, 2008
                  Hello Ilja!
                  First of all I want to answer on your direct question - yes you should
                  write different method for negative case because its code is
                  completely different from the positive case. In general, you should
                  write one method that test valid input and another method that test
                  invalid input (and typically throws exception).

                  I want to advice you to use @RunWith(Parameterized.class) with
                  @Parameters in JUnit 4 or TestSuite in JUnit 3.8 if you use it. If you
                  want I can post you examples of either code.

                  In the factorial method I would consider you to split you input to
                  following equivalence classes:
                  1. some small positive number that is grater to 1;
                  2. 0, 1 - boundary points;
                  3. -1 - boundary invalid point;
                  4. -1 and some negative number that is not -1;
                  5. some big positive number.

                  You should check last case (some big positive number) with
                  @Test(timeout=...) in JUnit 4 or to write down some code in JUnit 3.8.
                  Factorial of big number can take a lot of time. It can also cause
                  overflow. You should consider what behaviour you expects.

                  I would write one method for equivalence class 1 and 2, another method
                  for equivalence class 3 and 4 and separate method for equivalence
                  class 5.

                  --- In junit@yahoogroups.com, Veera Raghav Reddy <veerapulagam@...> wrote:
                  >
                  > Hi Ilja,
                  >
                  > Thanks for your kind response.
                  >
                  > Shall I have to write same method once agian for different set of
                  data(for negative cases)
                  >
                  > Please answer this query
                  >
                  > Thanks,
                  > Raghava
                  >
                  > Ilja Preuss <it@...> wrote:
                  > First, you probably should get rid of a lot of the boiler
                  plate code in
                  > your test.
                  >
                  > The catch block is not needed - just let the exception propagate, JUnit
                  > will recognize this as a failed test.
                  >
                  > You shouldn't all those System.out statements. The JUnit runner should
                  > you provide with enough info (use a different one if it doesn't).
                  >
                  > And for the reporting, use either your own implementation of a
                  > TestListener (I think that's the current API?), or use for example the
                  > Ant task(s).
                  >
                  > Then your tests look like this:
                  >
                  > > protected void setUp() throws java.lang.Exception {
                  > > mgr=EntitlementManager.getInstance().getRoleManager();
                  > > }
                  > >
                  > > public void testAddDelegatedRoles() {
                  > > String [] droles = {"PAP Application Group:PAP
                  > Application:guest"};
                  > > Date d1 = new Date();
                  > > HashMap h1 = new HashMap();
                  > > h1.put("k1",d1);
                  > > this.mgr.addDelegatedRoles(droles,"Application","Prime
                  > group:Prime portal",h1,"Default Domain");
                  > > }
                  > >
                  > > }
                  >
                  > So what this probably should test is the addDelegateRoles method, which
                  > takes 5 parameters. What is missing, though, is some kind of assertion
                  > that the method did what it should do. What should that method do?
                  >
                  > Cheers, Ilja
                  >
                  > Veera Raghav Reddy wrote:
                  > > Hi Ilja,
                  > >
                  > > Thanks for your kind response...
                  > >
                  > >
                  > > Here I am providing the sample test script that we are using,
                  please suggest me the best way to test this kind of requirement
                  > >
                  > > package net.project.tests.webservices.clients;
                  > >
                  > > import java.io.FileOutputStream;
                  > > import junit.framework.*;
                  > >
                  > > import net.project.api.pep.*;
                  > > import java.util.*;
                  > > import java.util.ArrayList;
                  > > import java.util.HashMap;
                  > > import net.project.api.pap.role.*;
                  > > import net.project.api.pap.application.*;
                  > > import net.project.api.vo.ApplicationGroup;
                  > > import net.project.api.vo.Application;
                  > > import net.project.api.vo.Role;
                  > > import net.project.api.vo.*;
                  > >
                  > >
                  > > public class TestRoleAPI extends TestCase {
                  > >
                  > > private IRole mgr = null;
                  > > FileOutputStream fos = null;
                  > > public TestRoleAPI(String testName) {
                  > > super(testName);
                  > > try{
                  > > fos = new FileOutputStream("../Java_PAPAPI_Report.txt",true);
                  > > }catch(Exception ex){ex.printStackTrace();}
                  > > }
                  > >
                  > > protected void setUp() throws java.lang.Exception {
                  > > mgr=EntitlementManager.getInstance().getRoleManager();
                  > >
                  > > }
                  > >
                  > > protected void tearDown() throws java.lang.Exception {
                  > > }
                  > >
                  > > /* public static junit.framework.Test suite() {
                  > > junit.framework.TestSuite suite = new
                  junit.framework.TestSuite(TestRoleAPI.class);
                  > > return suite;
                  > > }*/
                  > >
                  > >
                  > > public void testAddDelegatedRoles() {
                  > >
                  > > try{
                  > > //public void addDelegatedRoles(String delegatedRoles[],String
                  delegateType, String applicationOrGroupName,HashMap map,String
                  repositoryName) throws NoSuchRoleException, BaseException;
                  > > String [] droles = {"PAP Application Group:PAP Application:guest"};
                  > >
                  > > Date d1 = new Date();
                  > > HashMap h1 = new HashMap();
                  > > h1.put("k1",d1);
                  > > this.mgr.addDelegatedRoles(droles,"Application","Prime group:Prime
                  portal",h1,"Default Domain");
                  > >
                  > > System.out.println("===================================");
                  > > System.out.println("Test Succuss::AddDelegatedRoles");
                  > > System.out.println("===================================");
                  > > fos.write("Role_01 -- addDelegatedRoles() -- Success\r\n".getBytes());
                  > >
                  > > }catch(Exception ex)
                  > > {
                  > > try{
                  > > fos.write("Role_01 -- addDelegatedRoles() -- Failure\r\n".getBytes());
                  > > System.out.println("===================================");
                  > > System.out.println("Test Failed:: AddDelegatedRoles ");
                  > > fail("Test failed");
                  > > System.out.println("===================================");
                  > > }catch(Exception ex1){}
                  > > }
                  > > }
                  > >
                  > >
                  > >
                  > > }
                  > >
                  > >
                  > > Thanks,
                  > > Raghava
                  > >
                  > > Ilja Preuss <it@...> wrote: Hi Raghva,
                  > >
                  > > I'm not sure I understand the question.
                  > >
                  > > Can you show us an example method with 4 parameters, and explain,
                  > > preferably with examples again, why you'd need 24 tests?
                  > >
                  > > Thanks,
                  > >
                  > > Ilja
                  > >
                  > > > I am working as QA Engineer
                  > > >
                  > > > I have a requirement for API testing where we have many
                  APIs(Approaximately
                  > > > 250),
                  > > > each API method is going to take 3 to 10 parameters.
                  > > >
                  > > > If i have suppose 4 parameters in a method, the possible cases
                  would be
                  > > > Factorial(4)=24.
                  > > > Is it advisable to prepare test scripts for all 24
                  methods(positive &
                  > > > negative)?.
                  > > >
                  > > > Method 1:Writing test scripts for each case( positive or
                  negative).ie 24
                  > > > cases for a method which takes 4 parameters
                  > > >
                  > > > Method 2:Preparing common script for a method, using parser read
                  parameters
                  > > > from an xml file and pass them to method
                  > > >
                  > > > Method 3:Preparing common script for a method, read parameters
                  from txt file
                  > > > and pass them to method
                  > > >
                  > > > Note:I have the similar requirement in C# also
                  > > >
                  > > > It would be more appreciated if you suggest me the suitable way
                  among the
                  > > > above methods
                  > > >
                  > > > Thanks in advance...
                  > > >
                  > > > Regards,
                  > > > Raghava
                  > > >
                  > > >
                  > > > _____
                  > > >
                  > > > Never miss a thing. Make Yahoo
                  > > > <http://us.rd.yahoo.com/evt=51438/*http://www.yahoo.com/r/hs>
                  your homepage.
                  > > >
                  > > >
                  > > >
                  > > > [Non-text portions of this message have been removed]
                  > > >
                  > > >
                  > > >
                  > > >
                  > > > Yahoo! Groups Links
                  > > >
                  > > >
                  > > >
                  > > >
                  > >
                  > >
                  > >
                  > >
                  > >
                  > >
                  > > ---------------------------------
                  > > Be a better friend, newshound, and know-it-all with Yahoo! Mobile.
                  Try it now.
                  > >
                  > > [Non-text portions of this message have been removed]
                  > >
                  > >
                  > >
                  > >
                  > > Yahoo! Groups Links
                  > >
                  > >
                  > >
                  > >
                  >
                  >
                  >
                  >
                  >
                  >
                  > ---------------------------------
                  > Be a better friend, newshound, and know-it-all with Yahoo! Mobile.
                  Try it now.
                  >
                  > [Non-text portions of this message have been removed]
                  >
                Your message has been successfully submitted and would be delivered to recipients shortly.