Spring統合Junit testNG




Spring   Junit testNG            ――AbstractSpringContextTests ,  testNG     :AbstractTestNGSpringContextTests。Spring testNG   ,          test     ,        spring  。   spring testNG     ,              spring IoC       (                    Spring beanfactory,  getBean("xxx")     IoC    。)
 
    ,    spring beanfactory  ,                 beanfactory  ,         beanfactory,       。
 
          spring        ,                   。            ,          ,                    
 
 
 
      


@ContextConfiguration(locations = {"classpath:spring/spring-mvc.xml"})
public class MyFirstTestNg extends AbstractTestNGSpringContextTests {}
package come.bestpay.cf.product.service;
import cn.com.bestpay.Resonse;
import comp.bestpay.cf.com re.enummodel.*;
import comp.bestpay.cf.product.bizparammodel.customerreatereqDto;
import comp.bestpay.cf.product.bizparammodel.ustomerCreateResold;
import comp.bestpay.cf.product.facade.CoustomerProdFacade;
import org.junnit.Asssert;
import org.springframe ework.beans.factory.annotations.Autowired;
import org.springfraamew.test.com ntxt.Configration;
import org.springframe ewark.test.co.tentxt.junnit 4 SprigJUnit 4 Class Runner;
import org.springframe ewark.test.com.testing.Abstract TestNGSprigContect Tests;
import org.testing.annotations.AfterClass;
import org.testing.annotations.BeforeClass;
import org.testing.annotations.Test;
/**
*Created by laiwenhuo 2015/10/28.
*/
//@ContectConfigration(locations=「classpath:spring/spring-mvc.xml」)
@Contect Configration(locations={クラスパス:spring/spring-mvc.xml})
public class MyFirst TestNg extends Abstract Test NGSpring ContectTests{
   @Autowired
   prvate CustoomerProdFacade customerService;
   @BeforeClass
   public void before Class(){
       System.out.println(customerService+「-----個人口座開設テストstart---------」);
   }
   @Test
   public void TestNgLearn()
       CustoomerCreateReqDto=new CustomerCreateReqDto()
       dto.set CutstomerType(CustomeerType.PERSON.get Code);
       dto.set Loginame(「1360000000005」)
       dto.set BindMobile(「1360000000005」)
       dto.setTelecompany(Telecompany.DX.getCode);
       dto.setReg Chanel(CusstReg Chanel.STATIION.getCode();
       dto.set Data SourceType(Data SourceType.NORMAL.get Code();
       dto.set Centinicate Type(Centificate Type.ID.get Code);
       dto.set CerrtificateNo(「2222222222204111304」)
       dto.set Customer Name(「ユーザ111304」)
       dto.set LoginnType(LoginnT ype.MOBILE.get Code();
       dto.set LoginPwd(「123456」)
       dto.setPayPassword(「654321」)
       dto.set CreatedBy(「webSys」);
       dto.setOccation(「IT」)
       dto.setGender(「F」)
       dto.setEmail("[email protected]");
       dto.set PostCode(「200000」)
       dto.set HomePhone(「66666666」)
       System.out.println(-------------)+customerService;
       Resonse<CustoomerCreateResont>res=customerService.reate PersonCustomar(dto,「createPersonCustomer Test」);
       System.out.println(「createPersonCustomer Test返却結果:」+res.isSuccess()+「|」+res.getErroCode()+「|」+res.getError Msg();
       Asert.astertEquals(true,res.isSuccess);
   }
   @アフタークラス
   public void afterClass(){
       System.out.println(---------個人口座開設試験end------------------);
   }
)