配置WebTestClient以始终执行某项操作

时间:2019-07-05 09:15:31

标签: java spring spring-test spring-restdocs

我正在尝试设置import React from 'react'; import ReactDOM from 'react-dom'; import './index.css'; import Login from './Login'; import * as serviceWorker from './serviceWorker'; import Dropdown from 'react-bootstrap/Dropdown'; import { Link } from 'react-router-dom'; import { BrowserRouter, Route } from "react-router-dom"; import './index.css'; import AssetView from './AssetView'; import DepartmentView from './DepartmentView'; import LocationView from './LocationView'; import EmployeeView from './EmployeeView'; import AddDepartment from './AddDepartment'; import AddLocation from './AddLocation'; const routing = ( <BrowserRouter> <div> <nav class="navbar navbar-dark fixed-top bg-dark flex-md-nowrap p-0"> <a class="navbar-brand col-sm-3 col-md-2 mr-0" href="#">Company name</a> <ul class="navbar-nav px-3"> <li class="nav-item dropdown"> <Dropdown> <Dropdown.Toggle variant="success" id="dropdown-basic"> Account </Dropdown.Toggle> <Dropdown.Menu> <Dropdown.Item href="#/action-1">Informations</Dropdown.Item> <Dropdown.Item href="#/action-2">Settings</Dropdown.Item> <Dropdown.Item href="#/action-3">Signout</Dropdown.Item> </Dropdown.Menu> </Dropdown> </li> </ul> </nav> <div class="container-fluid"> <div class="row"> <nav class="col-md-2 d-none d-md-block bg-light sidebar"> <div class="sidebar-sticky"> <ul class="nav flex-column"> <li class="nav-item"> <a class="nav-Link active" href="#"> <span data-feather="home"></span> Dashboard <span className="sr-only">(current)</span> </a> </li> <h6 className="sidebar-heading d-flex justify-content-between align-items-center px-3 mt-4 mb-1 text-muted"> <span>Assets Management</span> <a className="d-flex align-items-center text-muted" href="#"> <span data-feather="plus-circle" /> </a> </h6> <li className="nav-item"> <Link to="/AssetView"> <a class="nav-link" href="#"> <span data-feather="file"></span> View All Assets </a> </Link> </li> </ul> <h6 className="sidebar-heading d-flex justify-content-between align-items-center px-3 mt-4 mb-1 text-muted"> <span>Company Management</span> <a className="d-flex align-items-center text-muted" href="#"> <span data-feather="plus-circle" /> </a> </h6> <ul className="nav flex-column mb-2"> <li className="nav-item"> <Link to="/DepartmentView"> <a class="nav-link" href="#"> <span data-feather="file"></span> View All Departments </a> </Link> </li> <li className="nav-item"> <Link to="/AddDepartment"> <a class="nav-link" href="#"> <span data-feather="file"></span> Add New Department </a> </Link> </li> <li className="nav-item"> <Link to="/LocationView"> <a class="nav-link" href="#"> <span data-feather="file"></span> View All Locations </a> </Link> </li> <li className="nav-item"> <Link to="/AddLocation"> <a class="nav-link" href="#"> <span data-feather="file"></span> Add New Location </a> </Link> </li> </ul> <h6 className="sidebar-heading d-flex justify-content-between align-items-center px-3 mt-4 mb-1 text-muted"> <span>Employees Management</span> <a className="d-flex align-items-center text-muted" href="#"> <span data-feather="plus-circle" /> </a> </h6> <ul className="nav flex-column mb-2"> <li className="nav-item"> <Link to="/EmployeeView"> <a class="nav-link" href="#"> <span data-feather="file"></span> View All Employees </a> </Link> </li> </ul> </div> </nav> </div> </div> <Route exact path="/AssetView" component={AssetView} /> <Route path="/DepartmentView" component={DepartmentView} /> <Route path="/LocationView" component={LocationView} /> <Route path="/EmployeeView" component={EmployeeView} /> <Route path="/AddDepartment" component={AddDepartment} /> <Route path="/AddLocation" component={AddLocation} /> </div> </BrowserRouter> ) ReactDOM.render(routing, document.getElementById('root')); serviceWorker.unregister(); 以始终记录文档,就像我们可以使用WebTestClient一样。

可以将

MockMvc配置为始终执行某些操作,例如执行某些Spring Restdocs文档,例如:

MockMvcBuilders

反应式变量MockMvcBuilders.webAppContextSetup(context) .apply(documentationConfiguration(this.restDocumentation)) .alwaysDo(document(getClass().getSimpleName() + "_" + this.testName.getMethodName())) .build() 也会有这种可能吗?

WebTestClient

0 个答案:

没有答案