0

Recently, while running some tests, I wanted to use TestNG instead of JUnit.

however when I added the dependency to pom file, imported the jar files. imported annotation, when I ran it, it passes for JUnit, but it's failing for TestNG with NPE (NullPointerException)

java.lang.NullPointerException: Cannot invoke "org.springframework.context.ApplicationContext.getBean(java.lang.Class)" because "this.context" is null

can someone show me the way to fix this issue?

Thank you very much in advance!

elysium
  • 43
  • 7

1 Answers1

0

Make sure you have done the correct injection. Refer to the below answer -

https://stackoverflow.com/a/2608580/14899650

  • Thank you @Satyam, I looked at the post, it makes lots of sense. It seems like a workaround that still works. hope Spring will update to TestNG one day :) – elysium Dec 04 '22 at 17:56