测试软件

git教程:测试实习经常用到

准备工作

注册gerrit账户,请联系管理员zhangjk@rc.inesa.com帮助添加,并且激活用户。
登录http://10.200.46.42:8080,将自己的开发机的/root/.ssh/id_rsa.pub复制加入SSH Public Keys中。
如果是windows,在Git Bash中输入ssh-keygen -t rsa命令生成key,一般生成在用户目录下,如:C:\Users\inesa\.ssh,将id_rsa.pub复制加入SSH Public Keys中。
在开发机上下载代码

#git clone ssh://<你的用户名>@10.200.46.42:29418/inesa-test

每一个代码开发人员必须配置用户名和邮箱

#git config --global user.name "<your name>"
#git config --global user.email "<your email address>"

安装git-review

#yum install -y git-review

配置gerrit

#cd inesa-test/
# vim .git/config
添加:
[remote "gerrit"]
        url = ssh://<你的用户名>@10.200.46.42:29418/inesa-test
        fetch = +refs/heads/*:refs/remotes/gerrit/*

开发者开发并提交代码

现在编写的代码工作开始:

首先确认分支,第一次默认是在master上

#git branch

创建新的分支并切换(名称可随意填写)

#git checkout -b <new branch name>
  

接下来就可以做代码修改......

完成自我测试后,清除.pyc文件和所有不必要的提交文件。如果有新的文件,要运行add添加修改

#git add .
(相应的,删除已经提交过的文件,使用#git rm <文件名>)

进入提交状态

#git commit -a -s

提交状态要严格按照规范书写git commit:

<顶格写入你的模块名>: <一句话来描述你的修改内容>
 ---空行---
<具体的修改信息>
 ---空行---

一个例子:

  performance: finish first draft of memory stream test
   
  Finish test/performance/test_stream, in this way:
  1. boot up one instance
  2. make it ssh login without password
  3. ssh to the instance and execute stream test
  4. print all output info in instance to screen
   
  Signed-off-by: Zhang Jingke <zhangjk@rc.inesa.com>

增加了Jenkins在代码提交后自动测试并反馈测试结果至gerrit的流程,如果没有需要测试的具体用例,commit格式和以上保持不变,如果有则修改commit格式如下: 一个例子:

  performance: finish first draft of memory stream test
   
  Finish test/performance/test_stream, in this way:
  1. boot up one instance
  2. make it ssh login without password
  3. ssh to the instance and execute stream test
  4. print all output info in instance to screen
  runcases:(以下为case名称)
  新建网络不带子网
  修改网关名称
  
  Signed-off-by: Zhang Jingke <zhangjk@rc.inesa.com>

如果commit中没有runcases,Jenkins会跑默认case,如果有则会跑runcases中的case,然后在gerrit中可查看Jenkins测试结果

最后提交代码:

#git review

回到gerrit登录网页,在open状态的提交中找到自己的提交,添加reviewer,然后相关的审阅者就会收到邮件。

以上针对第一次使用git,之后每次有了新的修改之后步骤如下:

1. 提交代码

#git add -A
#git commit

2. 切换到master分支上,将本地master分支的代码更新到最新,以免后面提交时产生conflict

#git checkout master
#git pull origin master

3. 切换回自己的分支上进行review

#git checkout <your branch>
#git review

廖雪峰网站教程讲得很好:

链接:https://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000

posted on 2018-07-26 17:02  weijiangping  阅读(360)  评论(0编辑  收藏  举报

导航