您的位置:軟件測(cè)試 > 開源軟件測(cè)試 > 開源單元測(cè)試工具 > junit
Junit手動(dòng)/自動(dòng)加載spring配置文件
作者:網(wǎng)絡(luò)轉(zhuǎn)載 發(fā)布時(shí)間:[ 2015/9/22 14:25:01 ] 推薦標(biāo)簽:軟件測(cè)試工具 單元測(cè)試工具

  分配置文件在classpath下和web-inf下兩種情況的加載:
ApplicationContext context = new FileSystemXmlApplicationContext("WebRoot/WEB-INF/applicationContext.xml");
new ClassPathXmlApplicationContext("applicationContext.xml");// 從classpath中加載
new FileSystemXmlApplicationContext("classpath:地址");// 沒有classpath表示當(dāng)前目錄
  注解加載
@org.springframework.test.context.ContextConfiguration(locations={"file:WebRoot/WEB-INF/applicationContext.xml"})
@org.springframework.test.context.ContextConfiguration(locations={"classpath:applicationContext.xml"})
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration({"classpath:/ut/applicationContext.xml"})
public class ScanDecisionFileTest {
@Before
public void setUp() throws Exception {
}
@After
public void tearDown() throws Exception {
}
@Test
public void testRun() {
//fail("Not yet implemented");
}
}

軟件測(cè)試工具 | 聯(lián)系我們 | 投訴建議 | 誠(chéng)聘英才 | 申請(qǐng)使用列表 | 網(wǎng)站地圖
滬ICP備07036474 2003-2017 版權(quán)所有 上海澤眾軟件科技有限公司 Shanghai ZeZhong Software Co.,Ltd