2012-02-17 5 views
0

私はスーパークラスとサブクラスを別々のパッケージに持っています。スーパークラスは@BeforeClass@BeforeMethodの注釈を持ちます。異なるパッケージの注釈付きスーパークラスをテストする

ただし、これらのメソッドは呼び出されません。両方のクラスを共通のパッケージに移動すると、どちらも@Before_xxメソッドが正常に呼び出されます。

スーパークラス:

package com.blah.focus.test.integration; 

import org.testng.annotations.BeforeClass; 
import org.testng.annotations.BeforeMethod; 

public class BookSuper { 

@BeforeClass(groups = "unit") 
void prepareDataSet() throws Exception { 
    System.out.println("Inside prepareDataSet");   
} 

/** 
* 
* @throws Exception 
*/ 
@BeforeMethod(groups = "unit") 
void beforeTestMethod() throws Exception { 
    System.out.println("Insde beforeTestMethod yy"); 

} 
} 

サブクラス:

package com.blah.focus.domain; 

public class BookTest extends BookSuper{ 
private Book book; 

@Test(groups = "unit") 
public void testGoodBookConstruction() { 
    book = new Book(); 
    book.setAuthor("Henry"); 
    book.setTitle("Good Title"); 
    book.setPublished(new Date()); 
    book.setPublisher("Rodale"); 
} 
} 

設計することで、このですか?

答えて

0

いや、それが動作するはずですし、それは私のための作業を行います。あなたは、おそらくいくつかの情報を省略している

Inside prepareDataSet 
Insde beforeTestMethod yy 

=============================================== 
SingleSuite 
Total tests run: 1, Failures: 0, Skips: 0 
=============================================== 

+0

まず第一に、セドリック・バーストのような人からの返事を得るのは本当に名誉です。ありがとうございました。そして、はい、私は(ひどく)ばかげたミスをしていました。説明しないだろう。 :-) – kmansoor

関連する問題