踏雪须眉 2018-06-15 05:57 采纳率: 0%
浏览 1751
已结题

Spring Junit 运行错误

[INFO ] Loaded default TestExecutionListener class names from location [META-INF/spring.factories]: [org.springframework.test.context.web.ServletTestExecutionListener, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener, org.springframework.test.context.support.DependencyInjectionTestExecutionListener, org.springframework.test.context.support.DirtiesContextTestExecutionListener, org.springframework.test.context.transaction.TransactionalTestExecutionListener, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener]
[INFO ] Could not instantiate TestExecutionListener [org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener]. Specify custom listener classes or make the default listener classes (and their required dependencies) available. Offending class: [org/springframework/transaction/interceptor/TransactionAttribute]
[INFO ] Could not instantiate TestExecutionListener [org.springframework.test.context.transaction.TransactionalTestExecutionListener]. Specify custom listener classes or make the default listener classes (and their required dependencies) available. Offending class: [org/springframework/transaction/interceptor/TransactionAttributeSource]
[INFO ] Using TestExecutionListeners: [org.springframework.test.context.web.ServletTestExecutionListener@234bef66, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener@737996a0, org.springframework.test.context.support.DependencyInjectionTestExecutionListener@61dc03ce, org.springframework.test.context.support.DirtiesContextTestExecutionListener@50f8360d]

代码如下:

package com.saikul.tracker.test;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.web.context.WebApplicationContext;

import sun.rmi.runtime.Log;

@WebAppConfiguration
@ContextConfiguration(locations = {"classpath:applicationContext.xml","classpath*:springmvc-servlet.xml"})
@RunWith(SpringJUnit4ClassRunner.class)
public class TestSaikulTracker {

    @Autowired
    private WebApplicationContext wac;

    private MockMvc mockMvc;


    @Before
    public void setup(){
        mockMvc = MockMvcBuilders.webAppContextSetup(wac).build();
    }


    @Test
    public void whenfetchData() throws Exception{
        String content = "[{'l':false}]";
        mockMvc.perform(MockMvcRequestBuilders.post("/api/updateParam").contentType(MediaType.APPLICATION_JSON_UTF8).content(content))
                    .andExpect(MockMvcResultMatchers.status().isOk());
    }

    @Test
    public void testJunitRunGood(){
        System.out.println("hello world ");
    }

}

基本上就是一个没有前端页面的,只提供服务的SSH项目,我加了两个jar 一个Junit的一个Spring test的,想要模拟mvc的访问restful服务
图片说明

  • 写回答

3条回答 默认 最新

  • 踏雪须眉 2018-06-19 02:41
    关注

    图片说明

    评论

报告相同问题?

悬赏问题

  • ¥15 flask项目,怎么使用AJAX传数据库数据到echarts图表的data里,实现异步加载数据。
  • ¥15 本题的答案是不是有问题
  • ¥15 关于#r语言#的问题:(svydesign)为什么在一个大的数据集中抽取了一个小数据集
  • ¥15 C++使用Gunplot
  • ¥15 这个电路是如何实现路灯控制器的,原理是什么,怎么求解灯亮起后熄灭的时间如图?
  • ¥15 matlab数字图像处理频率域滤波
  • ¥15 在abaqus做了二维正交切削模型,给刀具添加了超声振动条件后输出切削力为什么比普通切削增大这么多
  • ¥15 ELGamal和paillier计算效率谁快?
  • ¥15 蓝桥杯单片机第十三届第一场,整点继电器吸合,5s后断开出现了问题
  • ¥15 file converter 转换格式失败 报错 Error marking filters as finished,如何解决?