ServletContextは、サーブレットコンテナに依存するため、通常、サーバーを起動しないと使用できない。 そこで、JUnit上から、Springで、ServletContextをDIしてるクラスをテストするため、ServletContextをモッククラス(MockServletContext)と置き換えるようにしました。 テスト対象クラス import javax.servlet.ServletContext; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.context.annotation.Scope; @Componen