[사전작업]

빌드 환경 구성

테스트 환경 구성

 

 

테스트 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
블로그 이미지

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

,

[사전 작업]

Java JDK

Appium is installed

Android sdk is setup (for testing on android )

Xcode is setup (for testing on iOS)

Mobile device is ready for automation

Eclipse is installed

 

 

Appium 설치 관련

https://dejavuqa.tistory.com/222

 

Appium 서버 구성 (on Windows)

app 자동화 테스트를 위해 Windows에 Appium을 설치해 보겠습니다. 먼저 Java JDK를 설치해야 합니다. PC에 Java가 설치되어 있다면 넘어가셔도 됩니다. 아래 Oracle에 가서 JDK 8 Windows 버전을 다운로드 합니

dejavuqa.tistory.com

 

[관련환경 변수]

ANDROID_HOME=C:\Users\toast\AppData\Local\Android\Sdk
CLASSPATH=C:\Program Files\Java\jdk1.8.0_261\lib;.;
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_261
MAVEN=C:\apache-maven-3.6.3-bin\apache-maven-3.6.3
MAVEN_HOME=C:\apache-maven-3.6.3-bin\apache-maven-3.6.3
Path=C:\apache-maven-3.6.3-bin\apache-maven-3.6.3\bin;C:\Program Files\Java\jdk1.8.0_261\bin;C:\Users\toast\AppData\Local\Android\Sdk;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Users\toast\AppData\Local\Android\Sdk\platform-tools;F:\Tools\gradle-6.5.1-bin\bin

 

 

Install TestNG in Eclipse

아래 URL 들어가서 "Online Update-Site" 복사

https://github.com/cbeust/testng-eclipse/

 

cbeust/testng-eclipse

Eclipse plug-in for TestNG. Contribute to cbeust/testng-eclipse development by creating an account on GitHub.

github.com

 

[이클립스]

Help > Install New Software > Add.. 클릭 후 아래와 같이 작성

 

 

 

Create a new maven project

Add required lib/dependencies

maven을 이용한 아래의 라이브러리를 불러오기

Appium java client

Selenium java

TestNG

[pom.xml]

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.appium.Demo</groupId>
  <artifactId>AppiumDemoProject</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <name>POMframework</name>
  <url>http://maven.apache.org</url>
    
   <properties>
                        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
   </properties>

            <repositories>
                        <repository>
                                    <id>spring-releases</id>
                                    <name>Spring Releases</name>
                                    <url>https://repo.spring.io/libs-release</url>
                        </repository>
            </repositories>
            <pluginRepositories>
                        <pluginRepository>
                                    <id>spring-releases</id>
                                    <name>Spring Releases</name>
                                    <url>https://repo.spring.io/libs-release</url>
                        </pluginRepository>
            </pluginRepositories>
  
  
<dependencies>

	<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
	<dependency>
	    <groupId>org.seleniumhq.selenium</groupId>
	    <artifactId>selenium-java</artifactId>
	    <version>3.141.59</version>
	</dependency>
	
	<!-- https://mvnrepository.com/artifact/io.appium/java-client -->
	<dependency>
	    <groupId>io.appium</groupId>
	    <artifactId>java-client</artifactId>
	    <version>7.3.0</version>
	</dependency>
	
	<!-- https://mvnrepository.com/artifact/org.testng/testng -->
	<dependency>
	    <groupId>org.testng</groupId>
	    <artifactId>testng</artifactId>
	    <version>7.1.0</version>
	    <scope>compile</scope>
	</dependency>

</dependencies>

<build>
                        <plugins>
                                    <!-- Compiler plug-in -->
                                    <plugin>
                                                <groupId>org.apache.maven.plugins</groupId>
                                                <artifactId>maven-compiler-plugin</artifactId>
                                                <version>3.8.1</version>
                                                <configuration>
                                                            <source>1.8</source>
                                                            <target>1.8</target>
                                                </configuration>
                                    </plugin>
                                    
                                    <!-- Below plug-in is used to execute tests -->
                                    <plugin>
                                                <groupId>org.apache.maven.plugins</groupId>
                                                <artifactId>maven-surefire-plugin</artifactId>
                                                <version>2.18.1</version>
                                                <configuration>
                                                            <suiteXmlFiles>
                                                                        <!-- TestNG suite XML files -->
                                                                        <suiteXmlFile>testng.xml</suiteXmlFile>
                                                            </suiteXmlFiles>
                                                </configuration>
                                    </plugin>
                        </plugins>
 </build>

</project>

위의 내용은 아래 그림과 같이 mavenrepository에서 참고하여 복붙함

https://mvnrepository.com/ 에서 해당 library 검색

 

Save - Clean - Build project

자동으로 Maven이 해당 dependency를 참고하여 자동으로 관련 라이브러리가 추가된다

 

 

Create tests folders under src/main/java

User src/test/resources create a folder

 

 

Inside tests folder create a class - BaseClass

[BaseClass.java]

package baseClass;

import java.io.File;
import java.net.URL;
import java.util.concurrent.TimeUnit;

import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;

import io.appium.java_client.AppiumDriver;
import io.appium.java_client.MobileElement;

public class BaseClass {

    protected AppiumDriver<MobileElement> driver;

    @BeforeTest
    public void setup()  {
    	
        try {

      	File classpathRoot = new File(System.getProperty("user.dir"));
    	File appDir = new File(classpathRoot, "\\src\\test\\resources\\apps");
		File app = new File(appDir, "app-release-unsigned.apk");           	

        DesiredCapabilities cap = new DesiredCapabilities();
        cap.setCapability("deviceName", "sdk_gphone_x86");  //Phone model number
        cap.setCapability("udid", "emulator-5554");
        cap.setCapability("platformName", "Android");
        cap.setCapability("platformVersion", "11");
        cap.setCapability("app", app.getAbsolutePath());
        cap.setCapability("appPackage", "corp.doha.mypt");
        cap.setCapability("appActivity", "corp.doha.mypt.activity.StartActivity");
        
        URL url = new URL("http://localhost:4723/wd/hub");      

        driver = new AppiumDriver<MobileElement>(url, cap);
        driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
        driver.hideKeyboard();        
        Thread.sleep(5000);

        } catch(Exception exp) {
            System.out.println("Cause is : "+exp.getCause());
            System.out.println("Cause is : "+exp.getMessage());
            exp.printStackTrace();
        }

    }

  @Test
  public void sampleTest() {
      System.out.println("I am inside sample Test");
  }

  @AfterTest
  public void teardown() {
      driver.closeApp();        
      driver.quit();
    }

}

adb devices는 android studio를 이용해서 에뮬로 돌렸음

Desired Capabilities 관련 정보 얻는 방법은 아래 URL 참고

 

https://medium.com/@ivantay2003/appium-desired-capabilities-basic-cheat-sheet-to-launch-mobile-application-ios-android-75b664367031

 

Appium Desired Capabilities — Basic Cheat Sheet to Launch Mobile Application (iOS / Android)

Article is published and is updated as of 1st October 2019. This information may be outdated by the time you read it.

medium.com

 

 

Add test class and extend BaseClass

[TestScript1.java]

package testScripts;

import org.openqa.selenium.By;
import org.testng.annotations.Test;

import baseClass.BaseClass;
import io.appium.java_client.MobileElement;

public class TestScript1  extends BaseClass{
	
	@Test
	public void Login() throws InterruptedException{
		
//		MobileElement Inputid = driver.findElement(By.id("corp.doha.mypt:id/input_id"));		
//		Inputid.sendKeys("test");	
//		MobileElement Inputpw = driver.findElement(By.id("corp.doha.mypt:id/input_password"));		
//		Inputpw.sendKeys("test");				
		MobileElement Login = driver.findElement(By.id("corp.doha.mypt:id/button_login"));		
		Login.click();		
		System.out.println("Completed Test Login...");
		Thread.sleep(5000);
		
	}
	
}

 

위의 스크립트는 아래 API 문서 참고

http://appium.io/docs/en/about-appium/api/#appium-api-documentation

 

API Documentation - Appium

From here you can search these documents. Enter your search terms below.

appium.io

 

 

 Run & Test

1. Run Appium Server

2. Run TestScript1.java

 

 

[참고]

1. appium server 관련

아래와 같은 오류 대응은 아래 URL 참고하자

An unknown server-side error occurred while processing the command.
Original error: unknown error: Chrome version must be >= 55.0.2883.0

http://appium.io/docs/en/writing-running-appium/web/chromedriver/

 

Using Chromedriver - Appium

From here you can search these documents. Enter your search terms below.

appium.io

 

 

 

'APP Test > Appium' 카테고리의 다른 글

Hybrid App 스크립트 작성  (0) 2022.06.07
Linux 자동화 환경 구성  (0) 2022.06.07
블로그 이미지

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

,

사전 작업

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
블로그 이미지

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

,

Note - if you provide authorization at collection or folder level, In the request authorization, Select - "Inherit auth from parent"

When you add Authorization, some headers get added in the request, You can check by going to Headers tab and view hidden Headers

 

 

Search "github rest api on google" and Create Request Items

GitHub Repository를 생성하는 리퀘스트를 생성할 예정!

URL 참고 내역

https://developer.github.com/v3/

 

GitHub API v3

Get started with one of our guides, or jump straight into the API documentation.

developer.github.com

https://developer.github.com/v3/ 페이지 참고 부분

 

Endpoint 참고 내역

https://developer.github.com/v3/repos/

 

Repositories

Get started with one of our guides, or jump straight into the API documentation.

developer.github.com

https://developer.github.com/v3/repos/ 페이지 참고 부분
https://developer.github.com/v3/repos/ 페이지 참고 부분

 

아래와 같이 리퀘스트 생성!

{
    "name": "Hello-World Github",
    "description": "This is your first repository",
    "homepage": "https://github.com",
    "private": false,
    "has_issues": true,
    "has_projects": true,
    "has_wiki": true
}

 

 

Setting Request

Authorization > TYPE:Bearer Token > 아래 URL에서 생성한 토큰 입력

 

Github(로그인)접속 > Settings > Developer settings > Personal access tokens > Generate new token 클릭 > Select scopes에서 "repo" 부분만 클릭 > "Note" 에 토큰 이름 입력 후 생성

 

해당 토큰은 바로 입력 할 수 있지만 아래와 같이 변수 처리 할 수있다

Environment에서 해당 토큰을 변수처리함

 

 

Run

Postman 확인
github 확인

 

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

API Chaining Test 관련  (0) 2020.08.07
SOAP requests 구동  (0) 2020.08.07
Collection 원격 구동 with URL  (0) 2020.08.06
Data Driven Testing 관련  (0) 2020.08.06
WORKSPACES 관리  (0) 2020.08.06
블로그 이미지

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

,

API Chaining Test 란?

Get data from response of one API and refer in another API

 

 

Add requests in Postman and Use env variables to parameterize the value to be referred

 

아래와 같이 Collection, environment, Request 생성

POST Request 생성
GET Request 생성

 

 

Add scripts to fetch value from response of 1st API

bodyData = JSON.parse(responseBody)

value = bodyData.data[2].first_name

console.log(value)

pm.environment.set("Username1", value);

여기서 "value = bodyData.data[2].first_name" 이 부분은 아래를 통해 참고하였다.

 

[JSONPath Finder 관련]

크롬 확장 프로그램 설치 및 실행


확장 프로그램 실행 후 해당 JSON 데이터를 넣으면 아래와 같이 JSONPath를 찾을 수 있다.

 

 

 

Update the fetched value in env variables

Run and validate

아래와 같이 Variables 와 "UpdateUser" Request도 체인으로 업데이트 동작을 확인할 수 있다.

실행 전
실행 후 variables
실행 후 UpdateUser Request

 

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

API Authorization 관련  (0) 2020.08.07
SOAP requests 구동  (0) 2020.08.07
Collection 원격 구동 with URL  (0) 2020.08.06
Data Driven Testing 관련  (0) 2020.08.06
WORKSPACES 관리  (0) 2020.08.06
블로그 이미지

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

,

사전 작업

크롬 확장 프로그램 설치

 

 

Get Soap request url or WSDL url add to request url

아래 예제 URL을 참고하여 등록

http://webservices.oorsprong.org/websamples.countryinfo/CountryInfoService.wso?WSDL

 

 

Set method as POST

위의 URL 복사해서 아래와 같이 복붙

 

 

Set body as raw and set text/xml

 

 

Provide request data in body

위의 페이지에서 크롬 확장 프로그램 실행 후 아래와 같이 클릭

 

클릭하면 아래와 같이 해당 데이터가 나옴

 

아래와 같이 복사 붙여넣기

 

 

Run and validate

테스트 관련 코드를 "Tests"탭에 추가 후 구동!

 

Pubilc Link를 통해서도 테스트가 가능하다

C:\Users\toast>newman run https://www.getpostman.com/collections/600d1b0f5374e88fed46
newman

SOAP Collection

→ http://webservices.oorsprong.org/websamples.countryinfo/CountryInfoService.wso?WSDL
  POST http://webservices.oorsprong.org/websamples.countryinfo/CountryInfoService.wso?WSDL ――[200 OK, 564B, 684ms]
  √  Status code is 200

┌─────────────────────────┬────────────────────┬───────────────────┐
│                         │           executed │            failed │
├─────────────────────────┼────────────────────┼───────────────────┤
│              iterations │                  1 │                 0 │
├─────────────────────────┼────────────────────┼───────────────────┤
│                requests │                  1 │                 0 │
├─────────────────────────┼────────────────────┼───────────────────┤
│            test-scripts │                  1 │                 0 │
├─────────────────────────┼────────────────────┼───────────────────┤
│      prerequest-scripts │                  0 │                 0 │
├─────────────────────────┼────────────────────┼───────────────────┤
│              assertions │                  1 │                 0 │
├─────────────────────────┴────────────────────┴───────────────────┤
│ total run duration: 849ms                                        │
├──────────────────────────────────────────────────────────────────┤
│ total data received: 311B (approx)                               │
├──────────────────────────────────────────────────────────────────┤
│ average response time: 684ms [min: 684ms, max: 684ms, s.d.: 0µs] │

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

API Authorization 관련  (0) 2020.08.07
API Chaining Test 관련  (0) 2020.08.07
Collection 원격 구동 with URL  (0) 2020.08.06
Data Driven Testing 관련  (0) 2020.08.06
WORKSPACES 관리  (0) 2020.08.06
블로그 이미지

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

,

Get your collection url

Collection > Share > Get pubilc link > Get public link 클릭 후 해당 URL 복사

 

 

Get Newman and run with command

newman run "url"

 

실행 화면

 

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

API Chaining Test 관련  (0) 2020.08.07
SOAP requests 구동  (0) 2020.08.07
Data Driven Testing 관련  (0) 2020.08.06
WORKSPACES 관리  (0) 2020.08.06
Newman 관련  (0) 2020.08.06
블로그 이미지

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

,

Data variables can be used wherever environment variables can be used except in pre-request and test scripts

 

 

사전 작업

Request 생성

 

Tests 탭에는 아래와 같이 작성

tests["Contains email"] = responseBody.has(data.email);

tests["Contains password"] = responseBody.has(data["password"]);

 

 

Get data from csv, json file

csv, json 파일을 아래와 같이 불러오고, "Preview"를 통하여 데이터를 미리 확인할 수 있다

 

 

Run data-driven Tests

실행을 누르면 아래와 같이 테스트 결과와 csv, json 파일을 불러온 것을 확인할 수 있다.

 

테스트 데이터

data1.csv
0.00MB
data2.json
0.00MB

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

SOAP requests 구동  (0) 2020.08.07
Collection 원격 구동 with URL  (0) 2020.08.06
WORKSPACES 관리  (0) 2020.08.06
Newman 관련  (0) 2020.08.06
Tests 생성(Quick Scripts 활용)  (0) 2020.08.06
블로그 이미지

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

,