现在springboot整体测试程序如下:
package com.gwolf.test;
import com.gwolf.SampleController;
import junit.framework.TestCase;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import javax.annotation.Resource;
@SpringBootTest(classes = SampleController.class)
@RunWith(SpringJUnit4ClassRunner.class)
@WebAppConfiguration
public class TestSampleController {
@Resource
private SampleController sampleController;
@Test
public void testIndex() {
TestCase.assertEquals(this.sampleController.index(),
"Greetings from Spring Boot!");
}
}