单元测试搭建

master
shijie 4 years ago
parent 9ae34709fc
commit cae1d1917b
  1. 2
      src/main/java/com/yipin/liuwanr/Test.java
  2. 29
      src/test/java/com/yipin/liuwanr/CityServiceTest.java

@ -20,7 +20,7 @@ public class Test {
// System.out.println((new Test()).getURLContent(urlStr));
}
public static String getURLContent() throws Exception {
String strURL = "http://vip.stock.finance.sina.com.cn/quotes_service/api/json_v2.php/Market_Center.getHQNodeData?page=1&num=40&sort=symbol&asc=1&node=hs_a&symbol=&_s_r_a=init";
URL url = new URL(strURL);

@ -0,0 +1,29 @@
package com.yipin.liuwanr;
import com.yipin.liuwanr.entity.City;
import com.yipin.liuwanr.service.CityService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import java.util.HashMap;
@RunWith(SpringRunner.class)
@SpringBootTest
public class CityServiceTest {
@Autowired
private CityService cityService;
/**
* 新增城市信息方法测试
*/
@Test
public void testAddCity() {
City city = new City();
HashMap<String, Object> map = cityService.addCity(city);
map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value));
}
}
Loading…
Cancel
Save