2011-08-01 5 views
0

//でテストを実行しながら、私はちょうどselenium.open前に、nullポインタ例外エラーを取得していますTestNGのnullポインタ例外TestNGの

      package com.xyz.ngp.selenium; 

      import org.testng.annotations.*; 
      import javax.swing.*; 
      import com.thoughtworks.selenium.SeleneseTestNgHelper; 

      public class Grouping extends SeleneseTestNgHelper { 

       @BeforeGroups (groups = {"smoke"}) 
       public void oneTimeSetUp() {   
        try {   
         String st="we are in BeforeGroups"; 
         JOptionPane.showMessageDialog(null,st); 
         // scroll down to the bottom to see justprintsomething. 
         justprintsomething(); 
        } catch (Exception e) { 
         e.printStackTrace(); 
        }  
       } 

       @Test(groups = {"smoke"}) 
       public void test1() throws Exception { 
        String st="you wanted to execute smoke group"; 
        JOptionPane.showMessageDialog(null,st); 
       } 

       @Test(groups = {"functional"}) 
       public void test2() throws Exception { 
        String st="you wanted to execute : either (functional) or this test: (test2)"; 
        JOptionPane.showMessageDialog(null,st); 
       } 

       @Test(groups = {"test3"}) 
       public void test3() throws Exception { 
        String st="you wanted to execute : this test: (test3)"; 
        JOptionPane.showMessageDialog(null,st); 
       } 

       //@BeforeMethod (groups = "smoke") //do i need this beforegroups here? 
       public void justprintsomething() throws Exception {   
        try {   
         // it gets printed 
         String st="inside justprintsomething going to selenium.open"; 
         JOptionPane.showMessageDialog(null,st); 
         // if i comment out the below line code works fine 
         selenium.open("http://www.google.com/"); 
        } catch (Exception e) { 
         e.printStackTrace(); 
        }  
       } 

      } 

//を使用してそれらをグループ化することによって、テストケースを実行しようとしています。

+0

役に立つ答えを得るには、実際の(コンパイル可能な)コードを表示する必要があります。 –

答えて

0

セレンオブジェクトを初期化したことはありません。

+0

彼は実際にセレン変数を宣言しません。 –

+0

おかげで私は問題を解決しました。 null = seleniumの場合はインスタンスを作成します。 –