0
テストクラスにあるautowiredクラス(ListService)にアクセスできません。テストの外で、私は成功し、次の呼び出しにするautowiredクラスにアクセスすることができますAutowiredがTestNGテストクラスで動作しない
一覧をschoolSubjectList = listService.getMathSubjectList();
上記の呼び出しにより、NULLポインタ例外が発生します。
テストクラス:
...
@Autowired
ListService listService;
@BeforeClass
public void setUp(ITestContext context) throws Exception {
Random random = new Random();
int randomInteger = Math.abs(random.nextInt(1000));
suiteParams = context.getSuite().getXmlSuite().getAllParameters();
List<SchoolSubjectDto> schoolSubjectList = listService.getMathSubjectList();
int sizeOfSchoolSubjectList = schoolSubjectList.size();
...
mkyong.com/unittest/testng-spring-integration-exampleを参照してください?それはオートワイヤリングを担当するでしょう。 –
http://www.mkyong.com/unittest/testng-spring-integration-example/をご覧ください。素晴らしい例がありますか? –
@AlexandreFillatreあなたの答えは私のために働いた。回答として投稿してください。それはコミュニティに役立つでしょう。 –