Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
X
xyqb-user2
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
head_group
xyqb-user2
Commits
3a3a3c4f
Commit
3a3a3c4f
authored
Jan 08, 2018
by
技术部-任文超
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
提交jUnit测试Demo
parent
7c09b21d
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
84 additions
and
33 deletions
+84
-33
DemoApplicationTests.java
src/test/java/demo/DemoApplicationTests.java
+0
-32
DynamicTests.java
src/test/java/demo/DynamicTests.java
+6
-0
ParametersJunit4Tests.java
src/test/java/demo/ParametersJunit4Tests.java
+37
-0
ParametersJunit5Tests.java
src/test/java/demo/ParametersJunit5Tests.java
+40
-0
app.properties
src/test/resources/META-INF/app.properties
+1
-1
No files found.
src/test/java/demo/DemoApplicationTests.java
deleted
100644 → 0
View file @
7c09b21d
package
demo
;
import
cn.quantgroup.xyqb.Bootstrap
;
import
org.junit.Ignore
;
import
org.junit.Test
;
import
org.junit.jupiter.params.ParameterizedTest
;
import
org.junit.jupiter.params.provider.ValueSource
;
import
org.junit.runner.RunWith
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.test.context.junit4.SpringRunner
;
import
org.springframework.test.context.web.WebAppConfiguration
;
import
org.junit.Assert
;
@RunWith
(
SpringRunner
.
class
)
@SpringBootTest
(
classes
=
Bootstrap
.
class
)
@WebAppConfiguration
public
class
DemoApplicationTests
{
@ParameterizedTest
@ValueSource
(
strings
=
{
"racecar"
,
"radar"
,
"able was I ere I saw elba"
})
void
palindromes
(
String
candidate
)
{
Assert
.
assertNotNull
(
candidate
);
}
@Ignore
(
"Not Ready to Run"
)
@Test
public
void
loginFast
()
{
}
}
src/test/java/demo/DynamicTests.java
View file @
3a3a3c4f
...
...
@@ -19,6 +19,12 @@ import java.util.stream.Stream;
import
org.junit.jupiter.api.*
;
import
org.junit.jupiter.api.function.ThrowingConsumer
;
/**
* 动态批量测试
* @author renwc
* @date 2018-01-05
*/
@Tag
(
"Test Factory"
)
public
class
DynamicTests
{
...
...
src/test/java/demo/Parameters
Test
.java
→
src/test/java/demo/Parameters
Junit4Tests
.java
View file @
3a3a3c4f
package
demo
;
import
org.junit.Ignore
;
import
org.junit.jupiter.api.DisplayName
;
import
org.junit.Test
;
import
org.junit.jupiter.api.Tag
;
import
org.junit.jupiter.api.Test
;
import
org.junit.jupiter.api.TestInfo
;
import
org.junit.runner.RunWith
;
import
org.junit.runners.Parameterized
;
import
java.util.Arrays
;
import
java.util.Collection
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertEquals
;
/**
* jUnit4风格参数化批量测试(用例)
* @author renwc
* @date 2018-01-05
*/
@Tag
(
"Parameters"
)
@RunWith
(
value
=
Parameterized
.
class
)
public
class
Parameters
Test
{
public
class
Parameters
Junit4Tests
{
private
String
key
;
private
int
value
;
public
Parameters
Test
(
String
key
,
int
value
)
{
public
Parameters
Junit4Tests
(
String
key
,
int
value
)
{
this
.
key
=
key
;
this
.
value
=
value
;
}
@Parameterized
.
Parameters
public
Collection
<
Object
[]>
data
()
{
public
static
Collection
<
Object
[]>
data
()
{
Object
[][]
data
=
new
Object
[][]
{{
"1"
,
1
},
{
"2"
,
2
},
{
"3"
,
3
},
{
"4"
,
4
}};
return
Arrays
.
asList
(
data
);
}
...
...
@@ -34,12 +34,4 @@ public class ParametersTest {
System
.
out
.
println
(
"Parameterized is : key="
+
key
+
", value="
+
value
);
}
// @Ignore("Not Ready to Run")
// @Test
// @DisplayName("My 1st JUnit 5 test! 😎")
// void myFirstTest(TestInfo testInfo) {
// assertEquals(2, Math.addExact(1, 1), "1 + 1 should equal 2");
// assertEquals("My 1st JUnit 5 test! 😎", testInfo.getDisplayName(), () -> "TestInfo is injected correctly");
// }
}
\ No newline at end of file
src/test/java/demo/ParametersJunit5Tests.java
0 → 100644
View file @
3a3a3c4f
package
demo
;
import
org.junit.Assert
;
import
org.junit.Ignore
;
import
org.junit.Test
;
import
org.junit.jupiter.api.DisplayName
;
import
org.junit.jupiter.api.Tag
;
import
org.junit.jupiter.api.TestInfo
;
import
org.junit.jupiter.params.ParameterizedTest
;
import
org.junit.jupiter.params.provider.ValueSource
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertEquals
;
/**
* jUnit5风格参数化批量测试(用例)
* @author renwc
* @date 2018-01-05
*/
@Tag
(
"Parameters"
)
public
class
ParametersJunit5Tests
{
@ParameterizedTest
@ValueSource
(
strings
=
{
"racecar"
,
"radar"
,
"able was I ere I saw elba"
})
void
palindromes
(
String
candidate
)
{
Assert
.
assertNotNull
(
candidate
);
}
@Ignore
(
"Not Ready to Run"
)
@Test
public
void
loginFast
()
{
System
.
out
.
println
(
"Not Ready to Run"
);
}
@Ignore
(
"Not Ready to Run"
)
@DisplayName
(
"My 1st JUnit 5 test! 😎"
)
@org
.
junit
.
jupiter
.
api
.
Test
public
void
myFirstTest
(
TestInfo
testInfo
)
{
assertEquals
(
2
,
Math
.
addExact
(
1
,
1
),
"1 + 1 should equal 2"
);
assertEquals
(
"My 1st JUnit 5 test! 😎"
,
testInfo
.
getDisplayName
(),
()
->
"TestInfo is injected correctly"
);
}
}
\ No newline at end of file
src/test/resources/META-INF/app.properties
View file @
3a3a3c4f
app.id
=
xyqb-user2
namespace
=
application
\ No newline at end of file
namespace
=
application,tech.msg.sdk,tech.sleuth,tech.common,tech.service.urls,cash.common
\ No newline at end of file
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