해당 문서에는 Jenkins와 RobotFrameowrk & TestLink를 연동하는 내용을 설명합니다.

설치에 대한 내용은 생략합니다.

 

 

[TestLink 관련 설정]

TestLink 서버 접속하여 아래와 같이 "config.inc.pnp" 파일 설정 변경

$ tlCfg-> api-> enabled = TRUE;
$ tlCfg-> exec_cfg-> enabled_test_automation = ENABLED;

 

테스트 프로젝트 설정 확인

메인화면 > 테스트 프로젝트 관리 > 해당 프로젝트 클릭

 

테스트 계획 설정 사전 확인

"사용함" 및 "Pubilc"인 상태가 되어야 함(당연한 얘기지만)

메인화면 > 테스트 계획 관리

테스트 플랜 이름은 영어로!

테스트 플랜 이름이 한글이면 뿔난 젠킨스씨를 만나게 될 것이야!

 

사용자 정의 필드 생성

RobotFramework와 매칭 될 사용자 정의 필드를 생성한다

메인화면(해당 테스트프로젝트) > 사용자 필드 정의 > 생성

 

사용자 필드 지정

앞서 생성한 사용자 정의 필드가 RobotFramework의 매칭 될 부분을 지정한다

필자는 RobotFramework의 테스트 케이스와 테스트 링크 테스트 케이스와 1:1 매칭 하기 위해 아래와 같이 설정하였다.

메인화면(해당 테스트프로젝트) > 사용자 필드 지정 > 생성한 사용자 필드 체크 > 지정 클릭

 

플랫폼 확인 및 지정

메인화면(해당 테스트프로젝트) > Platform Management

 

테스트 케이스 설정 확인

테스트 케이스의 설정을 아래와 같이 설정해준다

실행 형태 : Automated

아래 사용자 정의 필드 생성한 항목이 있다. 해당 항목은 RobotFramework 스크립트의 해당 테스트 케이스 이름으로 입력!

 

테스트 케이스 추가 확인

아래와 같이 해당 플랫폼에 해당 테스트케이스가 해당 사용자로 추가가 되어야 한다.

요구 항목 : 테스트 계획, 테스트 플랜, 테스트 플랫폼, 테스트 케이스, 테스터 

 

 


[Jenkins관련 설정]

1. Jenkins와 관련된 TestLink Server 개인 API 정보 설정

Jenkins 관리 > 시스템 설정 > TestLink

 

Name : Toast(해당 API 키를 구분할 수 있으면 됨)

URL : http://"TestLinkServerIP"/lib/api/xmlrpc/v1/xmlrpc.php

[테스트 링크 서버 IP]/xmlrpc.php파일위치/xmlrpc.php

파일 위치는 테스트 링크 버전마다 다를 수 있으므로 해당 서버에 접속해서 위치 확인 후 입력

Developer Key : 아래 그림파일 참고하여 개인 API 접근 키 복붙

사용자를 여러 명 입력하고 싶으면 아래 추가 버튼을 눌러 해당 개인 API 접근키로 등록!

테스트링크 > 사용자정보 > API 인터페이스 > 개인 API 접근 키

추후 테스트 링크에 자동 입력될 사용자

 

 

2. Jenkins JOB 별 RobotFramework Plugin 관련 설정

"오래된 빌드 삭제 > 보관할 최대 개수 1" : 테스트 결과는 테스트 링크와 연동되어 자동으로 기록되어있기 때문에 1개로 함

"Restrict where this project can be run" : 해당 Job이 수행될 Agent 설정(기존에 등록한 Jenkins Agent 등록)

"사용자 빌드 경로 사용" : 빌드가 최초 실행될 디렉터리 지정

 

RobotFramework 스크립트 파일을 실행시키는 윈도우 배치 파일 커맨드를 아래와 같이 작성

[간략 설명]

해당 해당 스크립트를 실행하고 해당 테스트가 Pass 가되면 결과 파일(junit.xml)을 남기고

해당 테스트가 Fail 시 한번 더 실행해서 최초 실행 결과 파일과 머지하여 최종 결과 파일(junit.xml)을 남긴다

cd C:\AutoTest\Server\Target
::Executable
:: clean previous output files
@echo off
rd /s /q Results_Target
echo #######################################
echo # Running tests first time 	   #
echo #######################################
robot -x original_junit.xml --output original.xml -d Results_Target 1_1_1_2_Target.robot
:: we stop the script here if all the tests were OK
if errorlevel 1 goto DGTFO
echo #######################################
echo # Tests passed, no rerun 		   #
echo #######################################
:: we keep a copy of the first output file (added)
copy Results_Target\original.xml Results_Target\output.xml /Y
copy Results_Target\original_junit.xml Results_Target\junit.xml /Y
exit /b
:: otherwise we go for another round with the failing tests
:DGTFO
:: we keep a copy of the first log file
copy Results_Target\log.html Results_Target\first_run_log.html /Y

:: we launch the tests that failed
echo #######################################
echo # Running again the tests that failed #
echo #######################################
cd Results_Target
del /q original_junit.xml
robot -R original.xml --output rerun.xml "\AutoTest\Server\Target\1_1_1_2_Target.robot"
:: Robot Framework generates file rerun.xml

:: we keep a copy of the second log file
copy log.html second_run_log.html /Y

:: Merging output files
echo ########################
echo # Merging output files #
echo ########################
rebot --NoStatusRC -x junit.xml --output output.xml -R original.xml rerun.xml
:: Robot Framework generates a new output.xml

 

 

3. Jenkins JOB 별 TestLink Plugin 관련 설정

프로젝트 > 구성 > Build > Add build step > Invoke TestLink

TestLink Version : Jenkins와 관련된 TestLink Server 정보 설정에서 설정한 버전 선택

Test Project Name : 연동할 TestLink의 테스트 프로젝트 이름

Test Plan Name : 연동 할 TestLink의 테스트 계획 이름

Build Name : 연동 할 TestLink의 빌드 이름

Custom Fields : 연동 할 TestLink의 사용자 필드 이름

Platform Name : 연동 할 TestLink의 플랫폼 이름(고급 버튼 클릭 시 활성화)

 

프로젝트 > 구성 > Build > Add build step > Result Seeking Strategy

Include Pattern : junit파일 이름

사용자 빌드 경로가 적용되므로 경로를 입력하지 않는다.

Key Custom Field : TestLink 사용자 정의 필드 이름

 

 

아래는 해당 빌드 후 조치에 대한 설정이다.

"Dritectory of Robot output" : C:\AutoTest\Server\Target\Results_Target

위의 배치 스크립트에서 지정한 테스트 결과 폴더


만약 파이프라인으로 JOB을 등록 시

빌드 실패 시 라인으로 빌드결과 알림(샘플)

node {
    try{
        stage("Test_PASS"){
            build job: 'Testlink_test'
        }
        stage("Test_Fail"){
            build job: 'Testlink_fail'
        }
        
    currentBuild.result = 'SUCCESS'
    }catch (err) {
        currentBuild.result = 'FAILURE'
    }
  
    stage 'Notify'
        notifyLINE('bigFEmC2IIlEOssfsfyjgX4Wuh7TDbmos6zU6CYOM7L', currentBuild.result)
}
  
def notifyLINE(token, result) {
    def isFailure = result == 'FAILURE'
      
    def url = 'https://notify-api.line.me/api/notify'
    def message = "Result is ${result}. \n${env.BUILD_URL}"
      
    sh "curl ${url} -H 'Authorization: Bearer ${token}' -F 'message=${message}' "
}

자세한 내용은 아래 URL 참고

https://plugins.jenkins.io/testlink/

 

TestLink

This plugin integrates Jenkins and TestLink.

plugins.jenkins.io

https://wiki.jenkins.io/display/JENKINS/Robot+Framework+Plugin

 

Robot Framework

This publisher stores Robot Framework test reports for builds and shows summaries of them in project and build views along with trend graph.

plugins.jenkins.io

 

'UI Test > Jenkins' 카테고리의 다른 글

Gitlab Webhook으로 Jenkins 빌드 자동화  (0) 2022.03.10
블로그 이미지

정신차려이각박한세상속에서

,

프로젝트 관련

APP Test 2020. 8. 13. 14:09

해당 페이지는 프로젝트에 관련해서 설명하는 페이지입니다.

자세한 설명은 해당 링크를 참고하시면 됩니다.

 

도커 컨테이너로 구성된 빌드서에서 빌드를 진행

빌드환경은 따로 구축하지 않고 도커 허브에 있는 이미지로 구성함

 

 

Maven, TestNG, AppiumClient를 통한 테스트 스크립트 작성

Appium은 Selenium 베이스라 어떤 언어로도 사용 가능하지만, Java 클라이언트가 가장 사용량이 많고, 그만큼 서포트가 빠르며 안정된 클라이언트이기 때문에 Java를 선택하였다

 

젠킨스를 통해 빌드 및 테스트 스크립트 실행

E2E(End-to-End) 테스트이기 때문에 실제로 테스트 할 모바일 테스트기기가 필요했다

필자는 안드로이드 스튜디오의 에뮬레이터를 이용하여 프로젝트를 진행하였다.

블로그 이미지

정신차려이각박한세상속에서

,

[사전작업]

빌드 환경 구성

테스트 환경 구성

 

 

테스트 JOB 생성

E2E 테스트이기 때문에 환경을 Jenkins Agent(윈도우)에서 실행하도록 아래와 같이 추가

General

빌드 JOB 결과 내려받은 APK 파일 위치를 지정해놓은 테스트 환경에 맞춰 변경

Build#1

 

테스트 실행 스크립트 작성

Build#1

 

파이프라인 생성

아래와 같이 파이프 라인 생성

필자는 테스트 결과를 라인으로 받고 싶어서 아래와 같이 수정함

node {
    try{
        stage("Build"){
            build job: 'build'
        }
        stage("TestAPP"){
            build job: 'test'
            currentBuild.result = 'SUCCESS'
        }
    }catch (err) {
        currentBuild.result = 'FAILURE'
    }
  
    stage 'Notify'
        notifyLINE('DRYSTdTkv4OsQAXOsJoChPmUTqj9aR99wwIv3OFCdJl', currentBuild.result)
}
  
def notifyLINE(token, result) {
    def isFailure = result == 'FAILURE'
      
    def url = 'https://notify-api.line.me/api/notify'
    def message = "Result is ${result}. \n${env.BUILD_URL}"
    def imageThumbnail = isFailure ? 'FAILED_IMAGE_THUMBNAIL' : ''
    def imageFullsize = isFailure ? 'FAILED_IMAGE_FULLSIZE' : ''
      
    sh "curl ${url} -H 'Authorization: Bearer ${token}' -F 'message=${message}' -F 'imageThumbnail=${imageThumbnail}' -F 'imageFullsize=${imageFullsize}'"
}

 

 

테스트

생성된 파이프라인 실행

Build > Test 순으로 동작함을 해당 에뮬레이터에서 확인 및 라인알람 확인

 

 

Jenkins 라인 연동 관련 참고 URL

https://notify-bot.line.me/doc/en/

 

LINE Notify

LINE Notify allows you to send web notifications from GitHub, IFTTT, Mackerel, and more directly to your LINE chats.

notify-bot.line.me

https://engineering.linecorp.com/ko/blog/using-line-notify-to-send-messages-to-line-from-the-command-line/

 

커맨드 라인에서 LINE에 메시지를 보낼 수 있는 LINE Notify - LINE ENGINEERING

들어가며 LINE Notify 개발을 담당하고 있는 Watanabe입니다. 개발자를 대상으로 LINE Notify를 사용하여 커맨드 라인에서 메시지를 보내는 방법을 소개하겠습니다. 기존에는 시스템적으로 LINE에 메시지

engineering.linecorp.com

 

'APP Test > 테스트 환경구성' 카테고리의 다른 글

Android Stuido Emulator  (0) 2020.08.13
Appium 구축  (0) 2020.08.13
빌드 환경 구성(Jenkins-Android-Docker)  (0) 2020.08.10
블로그 이미지

정신차려이각박한세상속에서

,

사전 작업

1. docker & docker-compose 설치

2. 볼륨 데이터 권한 설정

mkdir /data/jenkins-android-docker
sudo chown -R 1000:1000 /data/jenkins-android-docker

 

docker-compose를 이용한 실행

아래 URL 을 참고하여 필자는 docker-compose를 아래와 같이 작성하여 진행하였다

https://github.com/WindSekirun/Jenkins-Android-Docker

 

WindSekirun/Jenkins-Android-Docker

🐳 Docker image for Jenkins with Android. Contribute to WindSekirun/Jenkins-Android-Docker development by creating an account on GitHub.

github.com

[root@localhost ~]# cat docker-compose.yml
version: '3.1'

services:

  jenkins:
    image: windsekirun/jenkins-android-docker:1.1.2
    container_name: jenkins
    ports:
      - "8080:8080"
      - "50000:50000"
    volumes:
      - "/data/jenkins-android-docker:/home/jenkins_home"
      - "/var/run/docker.sock:/var/run/docker.sock"
	restart: always

[root@localhost ~]# docker-compose up
      
      

이후 젠킨스 초기 비번 등록 및 계정 생성은 생략

 

 

[Jenkins 빌드 관련 설정]

Jenkins 환경 변수 설정

Jenkins에 ANDROID_HOME 설정

Jenkins 관리 -> 시스템 설정 -> Global properties -> Environment variables (체크)

이름 : ANDROID_HOME
값 : /opt/android-sdk-linux

위의 값은 아래의 명령어로 관련 환경 변수 확인 가능(위의 URL에서 해당 파일 참고)

[root@localhost Jenkins-Android-Docker-master]# cat Dockerfile |grep ANDROID_HOME
ENV ANDROID_HOME /opt/android-sdk-linux

 

 

Jenkins JOB 생성 및 설정

안드로이드 프로젝트 등록

새로운 Item -> "Enter an item name" 프로젝트 이름작성, "Freestyle Project" 선택 후 OK

 

Git 서버 설정

소스 코드 관리에 "Git"선택

Repository URL에 자신의 Git 주소를 적는다.

Credentials는 "Add"를 눌러서 자신의 레포에 해당하는 아이디와 비밀번호를 적는다.

Git > Repositories > Add

 

Build, Build 후 조치 설정

"Add build step"을 눌러서 "Invoke Gradle script"를 선택

"Use Gradle Wrapper" 선택 후 Tasks에 "clean assemble" 작성

"빌드 후 조치 추가"를 눌러서 "Archive the artifacts"를 선택

Files to archive에 "*/.apk" 작성

 

Publish Over FTP 또는 Publish Over SSH Plugin을 이용하여 빌드된 apk 파일 전송(사전 설치 필요)

Jenkins > 환경설정

 

 

 

빌드가 잘되는지 테스트해보자!

아래의 "실행" 버튼을 누르면 빌드가 진행되고 아래의 경로에 apk 파일 생성 확인

 

 

 

[삽질의 흔적들]

1. SDK 라이센스 오류 관련

일부 안드로이드 라이센스 관련해서 오류가 나서 빌드가 실패 할 수도 있다

[젠킨스 오류 전문]

Could not determine the dependencies of task ':app:compileReleaseJavaWithJavac'.
> Failed to install the following Android SDK packages as some licences have not been accepted.
     build-tools;29.0.2 Android SDK Build-Tools 29.0.2
  To build this project, accept the SDK license agreements and install the missing components using the Android Studio SDK Manager.
  Alternatively, to transfer the license agreements from one workstation to another, see http://d.android.com/r/studio-ui/export-licenses.html

  Using Android SDK: /opt/android-sdk-linux

[해결]

젠킨스 컨테이너 접속하여 아래 명려어 실행하여 라이센스 관련 조치하자

yes | sdkmanager --licenses

 

 

[참고]

추가적으로 아래와 같이 Webhook을 설정해주면 깃허브에서 push되면 자동으로 빌드하도록 구성 할 수있음

https://yaboong.github.io/jenkins/2018/05/14/github-webhook-jenkins/

 

Jenkins 로 빌드 자동화하기 1 - GitHub 에 push 되면 자동 빌드하도록 구성

개요 GitHub private repository 에 소스를 push 했을때, Jenkins 서버에 webhook 을 날려서 자동으로 빌드가 되도록 세팅하는 과정을 알아본다.

yaboong.github.io

 

 

 

 

 

참고URL

: https://kkensu.tistory.com/59

: https://stackoverflow.com/questions/38096225/automatically-accept-all-sdk-licences

'APP Test > 테스트 환경구성' 카테고리의 다른 글

Android Stuido Emulator  (0) 2020.08.13
Appium 구축  (0) 2020.08.13
JENKINS 설정 및 테스트  (0) 2020.08.13
블로그 이미지

정신차려이각박한세상속에서

,

Newman 은 Postman의 Collection을 커맨드 라인에서 실행시켜준다!

 

 

전체적인 순서

1. Install node.js

2. Install newman

3. export collection and run from commandline

4. On cmd goto location of collection json file

5. Run command

 

 

check if node.js is already installed

cmd 창에서 아래와 같이 확인

node -v  
npm -v

 

 

1. Install node.js

만약 설치가 안되어있다면 아래 URL 참고하여 설치

https://nodejs.org/en/download/

 

Download | Node.js

Node.js® is a JavaScript runtime built on Chrome's V8 JavaScript engine.

nodejs.org

 

 

2. Install Newman

cmd 창에서 아래 명령어로 뉴맨 설치!

npm install -g newman

 

 

3. Export collection as json file

 

 

4. On cmd goto location of collection json file

5. Run command

예시 : newman run (exprot한 json 파일 명)

newman run collectionfilename.json

 

 

실행 화면

C:\Users\toast\Desktop\Postman>newman run Collection1.postman_collection.json
newman

Collection1

□ GET
└ GET User
  ┌
  │ 'Hello world...'
  │ 'Value for url variables is : https://reqres.in'
  │ 'POSTMAN'
  │ undefined
  └
  GET https://reqres.in/api/users/2  [200 OK, 1.08KB, 249ms]
  ┌
  │ 'Hello world...'
  │ 'Value for url variables is : https://reqres.in'
  │ 'POSTMAN'
  │ undefined
  └

└ GET UserList
  ┌
  │ 'Hello world...'
  │ 'Value for url variables is : https://reqres.in'
  │ 'POSTMAN'
  │ undefined
  └
  GET https://reqres.in/api/users?page=2 [200 OK, 1.78KB, 47ms]
  √  Verify Response time is less than 200ms
  √  Verify Status code is 200

└ ScriptsTest
  ┌
  │ 'Hello world...'
  │ 'Value for url variables is : https://reqres.in'
  │ 'POSTMAN'
  │ undefined
  └
  GET  [errored]
     runtime:extenstions~request: request url is empty

□ POST
└ User Registration
  ┌
  │ 'Hello world...'
  │ 'Value for url variables is : https://reqres.in'
  │ 'POSTMAN'
  │ undefined
  └
  GET  [errored]
     runtime:extenstions~request: request url is empty

┌─────────────────────────┬────────────────────┬────────────────────┐
│                         │           executed │             failed │
├─────────────────────────┼────────────────────┼────────────────────┤
│              iterations │                  1 │                  0 │
├─────────────────────────┼────────────────────┼────────────────────┤
│                requests │                  4 │                  2 │
├─────────────────────────┼────────────────────┼────────────────────┤
│            test-scripts │                  6 │                  0 │
├─────────────────────────┼────────────────────┼────────────────────┤
│      prerequest-scripts │                  5 │                  0 │
├─────────────────────────┼────────────────────┼────────────────────┤
│              assertions │                  2 │                  0 │
├─────────────────────────┴────────────────────┴────────────────────┤
│ total run duration: 729ms                                         │
├───────────────────────────────────────────────────────────────────┤
│ total data received: 1.58KB (approx)                              │
├───────────────────────────────────────────────────────────────────┤
│ average response time: 148ms [min: 47ms, max: 249ms, s.d.: 101ms] │
└───────────────────────────────────────────────────────────────────┘

  #  failure           detail

 1.  Error             runtime:extenstions~request: request url is empty
                       at request
                       inside "GET / ScriptsTest"

 2.  Error             runtime:extenstions~request: request url is empty
                       at request
                       inside "POST / User Registration"

 

 

Jenkins 활용 관련

아래와 같이 Newman 명령어로 JOB 생성하여 진행

 

'WEB API Test > Postman' 카테고리의 다른 글

Data Driven Testing 관련  (0) 2020.08.06
WORKSPACES 관리  (0) 2020.08.06
Tests 생성(Quick Scripts 활용)  (0) 2020.08.06
Environment 생성 및 활용  (0) 2020.08.06
VARIABLES 활용  (0) 2020.08.06
블로그 이미지

정신차려이각박한세상속에서

,