# springboot-test **Repository Path**: enzoism/springboot-test ## Basic Information - **Project Name**: springboot-test - **Description**: springboot-test,进行从无到有的软件测试 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-11-24 - **Last Updated**: 2020-12-18 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 创建Maven项目 * 1)创建一个空项目,进行第一个controller调用 * 2)SpringBoot整合BootStrap * 3)使用测试框架JUnit -- -- ## 1)创建一个空项目,进行第一个controller调用 直接创建maven项目,然后在Application中添加 ```java @SpringBootApplication @RestController public class SpringBootDemo1Application { public static void main(String[] args) { SpringApplication.run(SpringBootDemo1Application.class, args); } @GetMapping("/") public String index(){ return "Hello,Index!"; } } ``` -- -- ## 2)SpringBoot整合BootStrap * 将bootStrap和jquery资源文件放入到static中 * 将html页面放入到templates中 * application.yaml中配置thymeleaf ```yaml spring: # 模板引擎 thymeleaf: mode: HTML encoding: utf-8 # 禁用缓存 cache: false ``` -- -- ## 3)使用测试框架JUnit * 添加JUnit依赖 ```xml junit junit 4.12 ``` * 进行测试类编写 ``` @Test public void testAssert() { String obj1 = "junit"; String obj2 = "junit"; String obj3 = "test"; String obj4 = "test"; String obj5 = null; int var1 = 1; int var2 = 2; int[] arithmetic1 = {1, 2, 3}; int[] arithmetic2 = {1, 2, 3}; assertEquals(obj1, obj2); System.out.println("-----------------obj1和obj2相等"); assertSame(obj3, obj4); System.out.println("-----------------obj3和obj4相同"); assertNotSame(obj2, obj4); System.out.println("-----------------obj2和obj4不相同"); assertNotNull(obj1); System.out.println("-----------------obj1不为null"); assertNull(obj5); System.out.println("-----------------判断obj5为null"); assertArrayEquals(arithmetic1, arithmetic2); System.out.println("-----------------arithmetic1和arithmetic1相等"); //assertTrue("为真", var1 == var2); System.out.println("-----------------obj1和obj2相等"); } ```