Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
gitlab-ci-android
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸大学计算机学院
教师群组
宋海霞-shx
androidTest
gitlab-ci-android
提交
0a06e54c
提交
0a06e54c
11月 01, 2016
创建
作者:
Greyson Parrelli
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added a functional test.
上级
20c1caae
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
25 行增加
和
5 行删除
+25
-5
AddingTest.java
.../java/com/greysonparrelli/gitlabciandroid/AddingTest.java
+25
-5
没有找到文件。
app/src/androidTest/java/com/greysonparrelli/gitlabciandroid/
ExampleInstrumented
Test.java
→
app/src/androidTest/java/com/greysonparrelli/gitlabciandroid/
Adding
Test.java
浏览文件 @
0a06e54c
...
@@ -2,11 +2,20 @@ package com.greysonparrelli.gitlabciandroid;
...
@@ -2,11 +2,20 @@ package com.greysonparrelli.gitlabciandroid;
import
android.content.Context
;
import
android.content.Context
;
import
android.support.test.InstrumentationRegistry
;
import
android.support.test.InstrumentationRegistry
;
import
android.support.test.rule.ActivityTestRule
;
import
android.support.test.runner.AndroidJUnit4
;
import
android.support.test.runner.AndroidJUnit4
;
import
org.junit.Rule
;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.junit.runner.RunWith
;
import
static
android
.
support
.
test
.
espresso
.
Espresso
.
onView
;
import
static
android
.
support
.
test
.
espresso
.
action
.
ViewActions
.
click
;
import
static
android
.
support
.
test
.
espresso
.
action
.
ViewActions
.
closeSoftKeyboard
;
import
static
android
.
support
.
test
.
espresso
.
action
.
ViewActions
.
typeText
;
import
static
android
.
support
.
test
.
espresso
.
assertion
.
ViewAssertions
.
matches
;
import
static
android
.
support
.
test
.
espresso
.
matcher
.
ViewMatchers
.
withId
;
import
static
android
.
support
.
test
.
espresso
.
matcher
.
ViewMatchers
.
withText
;
import
static
org
.
junit
.
Assert
.*;
import
static
org
.
junit
.
Assert
.*;
/**
/**
...
@@ -15,12 +24,23 @@ import static org.junit.Assert.*;
...
@@ -15,12 +24,23 @@ import static org.junit.Assert.*;
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
*/
@RunWith
(
AndroidJUnit4
.
class
)
@RunWith
(
AndroidJUnit4
.
class
)
public
class
ExampleInstrumentedTest
{
public
class
AddingTest
{
@Rule
public
ActivityTestRule
<
MainActivity
>
mActivityRule
=
new
ActivityTestRule
<>(
MainActivity
.
class
);
@Test
@Test
public
void
useAppContext
()
throws
Exception
{
public
void
addNumbers
()
throws
Exception
{
// Context of the app under test.
// Enter numbers to be added
Context
appContext
=
InstrumentationRegistry
.
getTargetContext
();
onView
(
withId
(
R
.
id
.
num1
))
.
perform
(
typeText
(
"1"
),
closeSoftKeyboard
());
onView
(
withId
(
R
.
id
.
num2
))
.
perform
(
typeText
(
"2"
),
closeSoftKeyboard
());
// Click the calculate button
onView
(
withId
(
R
.
id
.
calc_button
)).
perform
(
click
());
assertEquals
(
"com.greysonparrelli.gitlabciandroid"
,
appContext
.
getPackageName
());
onView
(
withId
(
R
.
id
.
sum
))
.
check
(
matches
(
withText
(
"3"
)));
}
}
}
}
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论