Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
guns-vip
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
chenjunxiong
guns-vip
Commits
174e7cfb
Commit
174e7cfb
authored
May 21, 2017
by
fsn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
部门管理测试完成
parent
a05209de
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
73 additions
and
4 deletions
+73
-4
src/test/java/com/stylefeng/guns/base/BaseTest.java
+10
-4
src/test/java/com/stylefeng/guns/system/DeptTest.java
+63
-0
No files found.
src/test/java/com/stylefeng/guns/base/BaseTest.java
View file @
174e7cfb
...
@@ -5,18 +5,24 @@ import org.junit.Before;
...
@@ -5,18 +5,24 @@ import org.junit.Before;
import
org.junit.runner.RunWith
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.test.annotation.Rollback
;
import
org.springframework.test.context.junit4.SpringRunner
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
org.springframework.test.context.web.WebAppConfiguration
;
import
org.springframework.test.context.web.WebAppConfiguration
;
import
org.springframework.test.web.servlet.MockMvc
;
import
org.springframework.test.web.servlet.MockMvc
;
import
org.springframework.test.web.servlet.setup.MockMvcBuilders
;
import
org.springframework.test.web.servlet.setup.MockMvcBuilders
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.web.context.WebApplicationContext
;
import
org.springframework.web.context.WebApplicationContext
;
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
/**
* 基础测试类
*
* @author stylefeng
* @Date 2017/5/21 16:10
*/
@RunWith
(
SpringRunner
.
class
)
@SpringBootTest
(
classes
=
GunsApplication
.
class
)
@SpringBootTest
(
classes
=
GunsApplication
.
class
)
@WebAppConfiguration
@WebAppConfiguration
@
Rollback
@
Transactional
public
class
BaseTest
{
public
class
BaseTest
{
@Autowired
@Autowired
...
...
src/test/java/com/stylefeng/guns/system/DeptTest.java
0 → 100644
View file @
174e7cfb
package
com
.
stylefeng
.
guns
.
system
;
import
com.stylefeng.guns.base.BaseTest
;
import
com.stylefeng.guns.common.persistence.dao.DeptMapper
;
import
com.stylefeng.guns.common.persistence.model.Dept
;
import
com.stylefeng.guns.modular.system.dao.DeptDao
;
import
org.junit.Test
;
import
javax.annotation.Resource
;
import
java.util.List
;
import
java.util.Map
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
/**
* 字典服务测试
*
* @author fengshuonan
* @date 2017-04-27 17:05
*/
public
class
DeptTest
extends
BaseTest
{
@Resource
DeptDao
deptDao
;
@Resource
DeptMapper
deptMapper
;
@Test
public
void
addDeptTest
()
{
Dept
dept
=
new
Dept
();
dept
.
setFullname
(
"测试fullname"
);
dept
.
setNum
(
5
);
dept
.
setPid
(
1
);
dept
.
setSimplename
(
"测试"
);
dept
.
setTips
(
"测试tips"
);
dept
.
setVersion
(
1
);
Integer
insert
=
deptMapper
.
insert
(
dept
);
assertEquals
(
insert
,
new
Integer
(
1
));
}
@Test
public
void
updateTest
()
{
Dept
dept
=
this
.
deptMapper
.
selectById
(
24
);
dept
.
setTips
(
"哈哈"
);
boolean
flag
=
dept
.
updateById
();
assertTrue
(
flag
);
}
@Test
public
void
deleteTest
()
{
Dept
dept
=
this
.
deptMapper
.
selectById
(
24
);
Integer
integer
=
deptMapper
.
deleteById
(
dept
);
assertTrue
(
integer
>
0
);
}
@Test
public
void
listTest
()
{
List
<
Map
<
String
,
Object
>>
list
=
this
.
deptDao
.
list
(
"总公司"
);
assertTrue
(
list
.
size
()
>
0
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment