春のブートを開始することができません出力ExtentReportsレポートをTestNGの、春のブーツを使用します

例は、すべての準備ができてTestNGの対応する設定を行う必要があり、テストはまた、あなたがTestNGのを起動すると、構成された注入例はすべてNULLであることが判明し、単純に使用することはできませんされたら、それはエラーとなっています

これは次のように与えられます:

春を開始する方法を追加し、ポインティングにより、背後に偉大な神:

まず、アプリケーションを追加する、方法

輸入org.mybatis.spring.annotation.MapperScan;
輸入org.springframework.beans.factory.config.YamlPropertiesFactoryBean。
輸入org.springframework.boot.SpringApplication。
輸入org.springframework.boot.autoconfigure.SpringBootApplication。
輸入org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration。
輸入org.springframework.context.ApplicationContext;
輸入org.springframework.context.annotation.Bean。
輸入org.springframework.context.annotation.Configuration。
輸入org.springframework.context.support.PropertySourcesPlaceholderConfigurer。
インポートorg.springframework.core.io.ClassPathResource; 


@SpringBootApplication(除外 = MongoAutoConfigurationを。クラス
@MapperScan(basePackages = "com.example.demo.dao" 
@Configuration 
パブリック クラスアプリケーション{
     パブリック 静的 ブールが =開始;
    プライベート 静的のApplicationContextのApplicationContext。

    公共の 静的取得(){ApplicationContextの
         返しのApplicationContextを。
    } 
    パブリック 静的 ボイドメイン(文字列[]引数){ 
        のApplicationContext= SpringApplication.run(アプリケーションクラス、引数)。
        開始 = ; 
    } 
}

その後、追加のメソッド呼び出しは、テストケースで春のブートコードを開始します

 公共の 静的のApplicationContextのApplicationContext。
    @BeforeClass 
    公共 ボイド開始(){
         場合(!{Application.started)
            のApplicationContext = SpringApplication.run(応用。クラス); 
            Application.started = ; 
        } { 
            ApplicationContextの = Application.get()。
        } 
    }

あなたは、通常の春のブートを開始できるように、

 

おすすめ

転載: www.cnblogs.com/biyuting/p/11184334.html