0

単純なサービス クラス、AnalyzerService は、データベース内のストアド プロシージャを呼び出します。統合テストを実行して、サービスがストアド プロシージャを呼び出し、アナライザー クラスが動作した後に正しいデータが返されることを確認しようとしています。ただし、「null オブジェクトでメソッド calculateEstimateNumberOfPositions() を呼び出すことはできません」という恐ろしい例外が発生します。サービス オブジェクトが null なのはなぜですか? 私は何が欠けていますか?

ありがとう!

package foobar.analyze
import static org.junit.Assert.*
import org.junit.*
import foobar.analyze.AnalyzerService
//@TestFor(AnalyzerService)
class AnalyzerServiceTests {
    def AnalyzerService service
    def dataSource

    @Before
    void setUp() {    }

    @After
    void tearDown() {   }

    @Test
    void testcalculateEstimateNumberOfPositions() {
        String positionName = "crew"
        String city = "Great Neck"
        String state = "NY"
        int numberOfPositionsSought = 100
        int expectedNumberOfPositionsEstimate = 100
        def numberOfPositionsEstimate = service.calculateEstimateNumberOfPositions(positionName, city, state, numberOfPositionsSought)
        fail (numberOfPositionsEstimate != expectedNumberOfPositionsEstimate)
    }
}
4

1 に答える 1