Multiple class files in java file and testng.xml












0















I have two class files in the same java file. How do I call them both in the testng.xml classes list? For e.g I have two classes A and B and the java file name is obviously A.java with A as a class. How do I call the class B from testng.xml










share|improve this question





























    0















    I have two class files in the same java file. How do I call them both in the testng.xml classes list? For e.g I have two classes A and B and the java file name is obviously A.java with A as a class. How do I call the class B from testng.xml










    share|improve this question



























      0












      0








      0








      I have two class files in the same java file. How do I call them both in the testng.xml classes list? For e.g I have two classes A and B and the java file name is obviously A.java with A as a class. How do I call the class B from testng.xml










      share|improve this question
















      I have two class files in the same java file. How do I call them both in the testng.xml classes list? For e.g I have two classes A and B and the java file name is obviously A.java with A as a class. How do I call the class B from testng.xml







      java selenium automation testng testng-eclipse






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 26 '18 at 11:44









      Geof

      315




      315










      asked Nov 26 '18 at 7:22









      Ragavendar 1Ragavendar 1

      1




      1
























          1 Answer
          1






          active

          oldest

          votes


















          0














          You would basically use the $ symbol to refer to inner classes.



          Assuming you have a sample such as the one shown below



          package com.rationaleemotions.stackoverflow.qn53476365;

          import org.testng.annotations.Test;

          public class SampleClass {

          @Test
          public void testMethod() {
          System.err.println("Hello from SampleClass");
          }

          public static class InnerClass {

          @Test
          public void testMethod() {
          System.err.println("Hello from InnerClass");
          }
          }
          }


          You would refer to the InnerClass as shown below in your testng.xml file



          <?xml version="1.0" encoding="UTF-8"?>
          <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
          <suite name="53476365_Suite" parallel="false" verbose="2">
          <test name="53476365_Test">
          <classes>
          <class name="com.rationaleemotions.stackoverflow.qn53476365.SampleClass"/>
          <class name="com.rationaleemotions.stackoverflow.qn53476365.SampleClass$InnerClass"/>
          </classes>
          </test>
          </suite>


          Output is as below



          ...
          ... TestNG 7.0.0-beta1 by Cédric Beust (cedric@beust.com)
          ...
          Hello from SampleClass

          Hello from InnerClass
          PASSED: testMethod
          PASSED: testMethod

          ===============================================
          53476365_Test
          Tests run: 2, Failures: 0, Skips: 0
          ===============================================

          ===============================================
          53476365_Suite
          Total tests run: 2, Passes: 2, Failures: 0, Skips: 0
          ===============================================


          Process finished with exit code 0





          share|improve this answer
























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53476365%2fmultiple-class-files-in-java-file-and-testng-xml%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            You would basically use the $ symbol to refer to inner classes.



            Assuming you have a sample such as the one shown below



            package com.rationaleemotions.stackoverflow.qn53476365;

            import org.testng.annotations.Test;

            public class SampleClass {

            @Test
            public void testMethod() {
            System.err.println("Hello from SampleClass");
            }

            public static class InnerClass {

            @Test
            public void testMethod() {
            System.err.println("Hello from InnerClass");
            }
            }
            }


            You would refer to the InnerClass as shown below in your testng.xml file



            <?xml version="1.0" encoding="UTF-8"?>
            <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
            <suite name="53476365_Suite" parallel="false" verbose="2">
            <test name="53476365_Test">
            <classes>
            <class name="com.rationaleemotions.stackoverflow.qn53476365.SampleClass"/>
            <class name="com.rationaleemotions.stackoverflow.qn53476365.SampleClass$InnerClass"/>
            </classes>
            </test>
            </suite>


            Output is as below



            ...
            ... TestNG 7.0.0-beta1 by Cédric Beust (cedric@beust.com)
            ...
            Hello from SampleClass

            Hello from InnerClass
            PASSED: testMethod
            PASSED: testMethod

            ===============================================
            53476365_Test
            Tests run: 2, Failures: 0, Skips: 0
            ===============================================

            ===============================================
            53476365_Suite
            Total tests run: 2, Passes: 2, Failures: 0, Skips: 0
            ===============================================


            Process finished with exit code 0





            share|improve this answer




























              0














              You would basically use the $ symbol to refer to inner classes.



              Assuming you have a sample such as the one shown below



              package com.rationaleemotions.stackoverflow.qn53476365;

              import org.testng.annotations.Test;

              public class SampleClass {

              @Test
              public void testMethod() {
              System.err.println("Hello from SampleClass");
              }

              public static class InnerClass {

              @Test
              public void testMethod() {
              System.err.println("Hello from InnerClass");
              }
              }
              }


              You would refer to the InnerClass as shown below in your testng.xml file



              <?xml version="1.0" encoding="UTF-8"?>
              <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
              <suite name="53476365_Suite" parallel="false" verbose="2">
              <test name="53476365_Test">
              <classes>
              <class name="com.rationaleemotions.stackoverflow.qn53476365.SampleClass"/>
              <class name="com.rationaleemotions.stackoverflow.qn53476365.SampleClass$InnerClass"/>
              </classes>
              </test>
              </suite>


              Output is as below



              ...
              ... TestNG 7.0.0-beta1 by Cédric Beust (cedric@beust.com)
              ...
              Hello from SampleClass

              Hello from InnerClass
              PASSED: testMethod
              PASSED: testMethod

              ===============================================
              53476365_Test
              Tests run: 2, Failures: 0, Skips: 0
              ===============================================

              ===============================================
              53476365_Suite
              Total tests run: 2, Passes: 2, Failures: 0, Skips: 0
              ===============================================


              Process finished with exit code 0





              share|improve this answer


























                0












                0








                0







                You would basically use the $ symbol to refer to inner classes.



                Assuming you have a sample such as the one shown below



                package com.rationaleemotions.stackoverflow.qn53476365;

                import org.testng.annotations.Test;

                public class SampleClass {

                @Test
                public void testMethod() {
                System.err.println("Hello from SampleClass");
                }

                public static class InnerClass {

                @Test
                public void testMethod() {
                System.err.println("Hello from InnerClass");
                }
                }
                }


                You would refer to the InnerClass as shown below in your testng.xml file



                <?xml version="1.0" encoding="UTF-8"?>
                <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
                <suite name="53476365_Suite" parallel="false" verbose="2">
                <test name="53476365_Test">
                <classes>
                <class name="com.rationaleemotions.stackoverflow.qn53476365.SampleClass"/>
                <class name="com.rationaleemotions.stackoverflow.qn53476365.SampleClass$InnerClass"/>
                </classes>
                </test>
                </suite>


                Output is as below



                ...
                ... TestNG 7.0.0-beta1 by Cédric Beust (cedric@beust.com)
                ...
                Hello from SampleClass

                Hello from InnerClass
                PASSED: testMethod
                PASSED: testMethod

                ===============================================
                53476365_Test
                Tests run: 2, Failures: 0, Skips: 0
                ===============================================

                ===============================================
                53476365_Suite
                Total tests run: 2, Passes: 2, Failures: 0, Skips: 0
                ===============================================


                Process finished with exit code 0





                share|improve this answer













                You would basically use the $ symbol to refer to inner classes.



                Assuming you have a sample such as the one shown below



                package com.rationaleemotions.stackoverflow.qn53476365;

                import org.testng.annotations.Test;

                public class SampleClass {

                @Test
                public void testMethod() {
                System.err.println("Hello from SampleClass");
                }

                public static class InnerClass {

                @Test
                public void testMethod() {
                System.err.println("Hello from InnerClass");
                }
                }
                }


                You would refer to the InnerClass as shown below in your testng.xml file



                <?xml version="1.0" encoding="UTF-8"?>
                <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
                <suite name="53476365_Suite" parallel="false" verbose="2">
                <test name="53476365_Test">
                <classes>
                <class name="com.rationaleemotions.stackoverflow.qn53476365.SampleClass"/>
                <class name="com.rationaleemotions.stackoverflow.qn53476365.SampleClass$InnerClass"/>
                </classes>
                </test>
                </suite>


                Output is as below



                ...
                ... TestNG 7.0.0-beta1 by Cédric Beust (cedric@beust.com)
                ...
                Hello from SampleClass

                Hello from InnerClass
                PASSED: testMethod
                PASSED: testMethod

                ===============================================
                53476365_Test
                Tests run: 2, Failures: 0, Skips: 0
                ===============================================

                ===============================================
                53476365_Suite
                Total tests run: 2, Passes: 2, Failures: 0, Skips: 0
                ===============================================


                Process finished with exit code 0






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 26 '18 at 13:03









                Krishnan MahadevanKrishnan Mahadevan

                9,01331744




                9,01331744
































                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53476365%2fmultiple-class-files-in-java-file-and-testng-xml%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    To store a contact into the json file from server.js file using a class in NodeJS

                    Marschland

                    Wiesbaden