Pytest測試框架3

目錄:

  1. pytest結合數據驅動-yaml
  2. pytest結合數據驅動-excel
  3. pytest結合數據驅動-csv
  4. pytest結合數據驅動-json
  5. pytest測試用例生命周期管理(一)
  6. pytest測試用例生命周期管理(二)
  7. pytest測試用例生命周期管理(三)
  8. pytest測試用例生命周期管理-自動注冊
  9. pytest測試用例生命周期管理-自動生效
  10. pytestfixture實現參數化

1.pytest結合數據驅動-yaml

數據驅動

  • 什么是數據驅動?

    • 數據驅動就是數據的改變從而驅動自動化測試的執行,最終引起測試結果的改變。簡單來說,就是參數化的應用。數據量小的測試用例可以使用代碼的參數化來實現數據驅動,數據量大的情況下建議大家使用一種結構化的文件(例如 yaml,json 等)來對數據進行存儲,然后在測試用例中讀取這些數據。
  • 應用:

    • App、Web、接口自動化測試
    • 測試步驟的數據驅動
    • 測試數據的數據驅動
    • 配置的數據驅動

yaml 文件介紹?

  • 對象:鍵值對的集合,用冒號 “:” 表示
  • 數組:一組按次序排列的值,前加 “-”
  • 純量:單個的、不可再分的值
    • 字符串
    • 布爾值
    • 整數
    • 浮點數
    • Null
    • 時間
    • 日期
# 編程語言
languages:- PHP- Java- Python
book:Python入門: # 書籍名稱price: 55.5author: Lilyavailable: Truerepertory: 20date: 2018-02-17Java入門:price: 60author: Lilyavailable: Falserepertory: Nulldate: 2018-05-11

yaml 文件使用

  • 查看 yaml 文件
    • pycharm
    • txt 記事本
  • 讀取 yaml 文件
    • 安裝:pip install pyyaml
    • 方法:yaml.safe_load(f)
    • 方法:yaml.safe_dump(f)
import yamlfile_path = './my.yaml'
with open(file_path, 'r', encoding='utf-8') as f:data = yaml.safe_load(f)

?代碼實例:

工程目錄結構

  • data 目錄:存放 yaml 數據文件
  • func 目錄:存放被測函數文件
  • testcase 目錄:存放測試用例文件
# 工程目錄結構
.
├── data
│   └── data.yaml
├── func
│   ├── __init__.py
│   └── operation.py
└── testcase├── __init__.py└── test_add.py

?測試準備

  • 被測對象:operation.py
  • 測試用例:test_add.py
  • 測試數據:data.yaml
# operation.py 文件內容
def my_add(x, y):result = x + yreturn result
# test_add.py 文件內容
class TestWithYAML:@pytest.mark.parametrize('x,y,expected', [[1, 1, 2]])def test_add(self, x, y, expected):assert my_add(int(x), int(y)) == int(expected)
# data.yaml 文件內容
-- 1- 1- 2
-- 3- 6- 9
-- 100- 200- 300
import pytest
import yamlfrom func.operation import my_add# 方法一
# class TestWithYAML:
#     @pytest.mark.parametrize('x,y,expected', [[1, 1, 2], [3, 6, 9], [100, 200, 300]])
#     def test_add(self, x, y, expected):
#         assert my_add(int(x), int(y)) == int(expected)# 方法二
def get_data():with open("../data/data.yaml", encoding='utf-8') as f:data = yaml.safe_load(f)return dataclass TestWithYAML:@pytest.mark.parametrize('x,y,expected', get_data())def test_add(self, x, y, expected):assert my_add(int(x), int(y)) == int(expected)

2.pytest結合數據驅動-excel

讀取 Excel 文件

  • 第三方庫

    • xlrd
    • xlwings
    • pandas
  • openpyxl

    • 官方文檔: https://openpyxl.readthedocs.io/en/stable/

openpyxl 庫的安裝

  • 安裝:pip install openpyxl
  • 導入:import openpyxl

openpyxl 庫的操作

  • 讀取工作簿

  • 讀取工作表

  • 讀取單元格

import openpyxl# 獲取工作簿
book = openpyxl.load_workbook('./data/test.xlsx')# 讀取工作表
sheet = book.active
print(sheet)# 讀取單個單元格
cell_a1 = sheet['A1']
print(cell_a1.value)cell_a3 = sheet.cell(column=1, row=3)  # A3
print(cell_a3.value)# 讀取多個連續單元格
cells = sheet["A1":"C3"]
for i in cells:for j in i:print(j.value,end=' ')print()

?代碼實例:

import openpyxl
import pytest
import yamlfrom func.operation import my_add# 方法一
# class TestWithYAML:
#     @pytest.mark.parametrize('x,y,expected', [[1, 1, 2], [3, 6, 9], [100, 200, 300]])
#     def test_add(self, x, y, expected):
#         assert my_add(int(x), int(y)) == int(expected)# 方法二
# def get_data():
#     with open("../data/data.yaml", encoding='utf-8') as f:
#         data = yaml.safe_load(f)
#     return data
#
#
# class TestWithYAML:
#     @pytest.mark.parametrize('x,y,expected', get_data())
#     def test_add(self, x, y, expected):
#         assert my_add(int(x), int(y)) == int(expected)# 方法三
def get_excel():book = openpyxl.load_workbook("../data/test.xlsx")sheet = book.activecells = sheet["A1":"C3"]values = []for row in cells:data = []for cell in row:data.append(cell.value)values.append(data)return valuesclass TestWithYAML:@pytest.mark.parametrize('x,y,expected', get_excel())def test_add(self, x, y, expected):assert my_add(int(x), int(y)) == int(expected)

3.pytest結合數據驅動-csv

csv 文件介紹

  • csv:逗號分隔值
  • 是 Comma-Separated Values 的縮寫
  • 以純文本形式存儲數字和文本
  • 文件由任意數目的記錄組成
  • 每行記錄由多個字段組成
Linux從入門到高級,linux,¥5000
web自動化測試進階,python,¥3000
app自動化測試進階,python,¥6000
Docker容器化技術,linux,¥5000
測試平臺開發與實戰,python,¥8000

?csv 文件使用

  • 讀取數據

    • 內置函數:open()
    • 內置模塊:csv
  • 方法:csv.reader(iterable)

    • 參數:iterable ,文件或列表對象
    • 返回:迭代器,每次迭代會返回一行數據。
import csvdef get_csv():with open('./data/params.csv', 'r', encoding='utf-8') as file:raw = csv.reader(file)for line in raw:print(line)if __name__ == '__main__':get_csv()

代碼實例:

測試準備

  • 被測對象:operation.py

  • 測試用例:test_add.py

  • 測試數據:params.csv

# operation.py 文件內容
def my_add(x, y):result = x + yreturn result# test_add.py 文件內容
class TestWithCSV:@pytest.mark.parametrize('x,y,expected', [[1, 1, 2]])def test_add(self, x, y, expected):assert my_add(int(x), int(y)) == int(expected)# params.csv 文件內容
1,1,2
3,6,9
100,200,300
import csvimport openpyxl
import pytest
import yamlfrom func.operation import my_add# 方法一
# class TestWithYAML:
#     @pytest.mark.parametrize('x,y,expected', [[1, 1, 2], [3, 6, 9], [100, 200, 300]])
#     def test_add(self, x, y, expected):
#         assert my_add(int(x), int(y)) == int(expected)# 方法二
# def get_data():
#     with open("../data/data.yaml", encoding='utf-8') as f:
#         data = yaml.safe_load(f)
#     return data
#
#
# class TestWithYAML:
#     @pytest.mark.parametrize('x,y,expected', get_data())
#     def test_add(self, x, y, expected):
#         assert my_add(int(x), int(y)) == int(expected)# 方法三
# def get_excel():
#     book = openpyxl.load_workbook("../data/test.xlsx")
#     sheet = book.active
#     cells = sheet["A1":"C3"]
#     values = []
#     for row in cells:
#         data = []
#         for cell in row:
#             data.append(cell.value)
#         values.append(data)
#     return values
#
#
# class TestWithYAML:
#     @pytest.mark.parametrize('x,y,expected', get_excel())
#     def test_add(self, x, y, expected):
#         assert my_add(int(x), int(y)) == int(expected)# 方法四
def get_csv():with open('../data/test.csv', encoding='utf-8') as f:raw = csv.reader(f)data = []for line in raw:data.append(line)return dataclass TestWithYAML:@pytest.mark.parametrize('x,y,expected', get_csv())def test_add(self, x, y, expected):assert my_add(int(x), int(y)) == int(expected)

4.pytest結合數據驅動-json

json 文件介紹

  • json 是 JS 對象

  • 全稱是 JavaScript Object Notation

  • 是一種輕量級的數據交換格式

  • json 結構

    • 對象?{"key": value}
    • 數組?[value1, value2 ...]
{"name:": "tom","detail": {"course": "python","city": "北京"},"remark": [1000, 666, 888]
}

?json 文件使用

  • 查看 json 文件
    • pycharm
    • txt 記事本
  • 讀取 json 文件
    • 內置函數 open()
    • 內置庫 json
    • 方法:json.loads()
    • 方法:json.dumps()

?params.json

{"case1": [1, 1, 2],"case2": [3, 6, 9],"case3": [100, 200, 300]
}
import jsondef get_json():with open('./data/params.json', 'r') as f:data = json.loads(f.read())print(data)print(type(data))s = json.dumps(data, ensure_ascii=False)print(s)print(type(s))if __name__ == '__main__':get_json()

代碼示例:

測試準備

  • 被測對象:operation.py

  • 測試用例:test_add.py

  • 測試數據:params.json

# operation.py 文件內容
def my_add(x, y):result = x + yreturn result# test_add.py 文件內容
class TestWithJSON:@pytest.mark.parametrize('x,y,expected', [[1, 1, 2]])def test_add(self, x, y, expected):assert my_add(int(x), int(y)) == int(expected)# params.json 文件內容
{"case1": [1, 1, 2],"case2": [3, 6, 9],"case3": [100, 200, 300]
}
import csv
import jsonimport openpyxl
import pytest
import yamlfrom func.operation import my_add# 方法一
# class TestWithYAML:
#     @pytest.mark.parametrize('x,y,expected', [[1, 1, 2], [3, 6, 9], [100, 200, 300]])
#     def test_add(self, x, y, expected):
#         assert my_add(int(x), int(y)) == int(expected)# 方法二
# def get_data():
#     with open("../data/data.yaml", encoding='utf-8') as f:
#         data = yaml.safe_load(f)
#     return data
#
#
# class TestWithYAML:
#     @pytest.mark.parametrize('x,y,expected', get_data())
#     def test_add(self, x, y, expected):
#         assert my_add(int(x), int(y)) == int(expected)# 方法三
# def get_excel():
#     book = openpyxl.load_workbook("../data/test.xlsx")
#     sheet = book.active
#     cells = sheet["A1":"C3"]
#     values = []
#     for row in cells:
#         data = []
#         for cell in row:
#             data.append(cell.value)
#         values.append(data)
#     return values
#
#
# class TestWithYAML:
#     @pytest.mark.parametrize('x,y,expected', get_excel())
#     def test_add(self, x, y, expected):
#         assert my_add(int(x), int(y)) == int(expected)# 方法四
# def get_csv():
#     with open('../data/test.csv', encoding='utf-8') as f:
#         raw = csv.reader(f)
#         data = []
#         for line in raw:
#             data.append(line)
#     return data
#
#
# class TestWithYAML:
#     @pytest.mark.parametrize('x,y,expected', get_csv())
#     def test_add(self, x, y, expected):
#         assert my_add(int(x), int(y)) == int(expected)# 方法五
def get_json():with open('../data/params.json', 'r') as f:data = json.loads(f.read())print(data)print(type(data))print(list(data.values()))return list(data.values())class TestWithYAML:@pytest.mark.parametrize('x,y,expected', get_json())def test_add(self, x, y, expected):assert my_add(int(x), int(y)) == int(expected)

5.pytest測試用例生命周期管理(一)

Fixture 特點及優勢

  • 1、命令靈活:對于 setup,teardown,可以不起這兩個名字
  • 2、數據共享:在 conftest.py 配置?寫?法可以實現數據共享,不需要 import 導?。可以跨?件共享
  • 3、scope 的層次及神奇的?yield?組合相當于各種 setup 和 teardown
  • 4、實現參數化

Fixture 在自動化中的應用- 基本用法

  • 場景:

測試?例執?時,有的?例需要登陸才能執?,有些?例不需要登陸。

setup 和 teardown ?法滿?。fixture 可以。默認 scope(范圍)function

  • 步驟:
    • 1.導? pytest
    • 2.在登陸的函數上?加@pytest.fixture()
    • 3.在要使?的測試?法中傳?(登陸函數名稱),就先登陸
    • 4.不傳?的就不登陸直接執?測試?法。
import pytest@pytest.fixture()
def login():print('完成登錄操作')def test_search():print('搜索')# def test_cart():
#     login()
#     print('購物車')def test_cart(login):print('購物車')def test_order(login):print('下單功能')

6.pytest測試用例生命周期管理(二)

Fixture 在自動化中的應用 - 作用域

取值范圍說明
function函數級每一個函數或方法都會調用
class類級別每個測試類只運行一次
module模塊級每一個.py 文件調用一次
package包級每一個 python 包只調用一次(暫不支持)
session會話級每次會話只需要運行一次,會話內所有方法及類,模塊都共享這個方法
import pytest@pytest.fixture(scope="function")
def login():print('完成登錄操作')def test_search():print('搜索')# def test_cart():
#     login()
#     print('購物車')def test_cart(login):print('購物車')def test_order(login):print('下單功能')class TestDemo:def test_case1(self, login):print("case1")def test_case2(self, login):print("case2")

7.pytest測試用例生命周期管理(三)

Fixture 在自動化中的應用 - yield 關鍵字

  • 場景:

你已經可以將測試?法【前要執?的或依賴的】解決了,測試?法后銷毀清除數據的要如何進?呢?

  • 解決:

通過在 fixture 函數中加? yield 關鍵字,yield 是調?第?次返回結果,第?次執?它下?的語句返回。

  • 步驟:

在@pytest.fixture(scope=module)。在登陸的?法中加 yield,之后加銷毀清除的步驟

import pytest
'''
@pytest.fixture
def fixture_name():setup 操作yield 返回值teardown 操作
'''@pytest.fixture(scope="function")
def login():#setup操作print('完成登錄操作')tocken = "abcdafafasdfds"username = 'tom'yield tocken,username #相當于return#teardown操作print('完成登出操作')def test_search():print('搜索')# def test_cart():
#     login()
#     print('購物車')def test_cart(login):print('購物車')def test_order(login):print('下單功能')class TestDemo:def test_case1(self, login):print("case1")def test_case2(self, login):print("case2")

8.pytest測試用例生命周期管理-自動注冊

Fixture 在自動化中的應用 - 數據共享

  • 場景:

與其他測試?程師合作?起開發時,公共的模塊要放在?家都訪問到的地?。

  • 解決:

使? conftest.py 這個?件進?數據共享,并且他可以放在不同位置起著不同的范圍共享作?。

  • 前提:

    • conftest ?件名是不能換的
    • 放在項?下是全局的數據共享的地?
  • 執?:

    • 系統執?到參數 login 時先從本模塊中查找是否有這個名字的變量什么的,
    • 之后在 conftest.py 中找是否有。
  • 步驟:

將登陸模塊帶@pytest.fixture 寫在 conftest.py 里面

代碼示例:

conftest.py

# conftest.py名字是固定的,不能改變
import pytest@pytest.fixture(scope="function")
def login():# setup操作print('完成登錄操作')tocken = "abcdafafasdfds"username = 'tom'yield tocken, username  # 相當于return# teardown操作print('完成登出操作')

test_test1.py

import pytest
'''
@pytest.fixture
def fixture_name():setup 操作yield 返回值teardown 操作
'''def test_search():print('搜索')# def test_cart():
#     login()
#     print('購物車')def test_cart(login):print('購物車')def test_order(login):print('下單功能')class TestDemo:def test_case1(self, login):print("case1")def test_case2(self, login):print("case2")

項目結構:

9.pytest測試用例生命周期管理-自動生效

Fixture 在自動化中的應用 - 自動應用

場景:

不想原測試?法有任何改動,或全部都?動實現?動應?,

沒特例,也都不需要返回值時可以選擇?動應?

解決:

使? fixture 中參數 autouse=True 實現

步驟:

在?法上?加?@pytest.fixture(autouse=True)

test_test1.py

import pytest'''
@pytest.fixture
def fixture_name():setup 操作yield 返回值teardown 操作
'''def test_search():print('搜索')# def test_cart():
#     login()
#     print('購物車')# def test_cart(login):
#     print('購物車')
def test_cart():print('購物車')# def test_order(login):
#     print('下單功能')def test_order():print('下單功能')class TestDemo:# def test_case1(self, login):#     print("case1")def test_case1(self):print("case1")# def test_case2(self, login):#     print("case2")def test_case2(self):print("case2")

?conftest.py

# conftest.py名字是固定的,不能改變
import pytest@pytest.fixture(scope="function", autouse=True)
def login():# setup操作print('完成登錄操作')tocken = "abcdafafasdfds"username = 'tom'yield tocken, username  # 相當于return# teardown操作print('完成登出操作')

運行結果:

?

?10.pytestfixture實現參數化

Fixture 在自動化中的應用 -參數化

場景:

測試離不開數據,為了數據靈活,?般數據都是通過參數傳的

解決:

fixture 通過固定參數 request 傳遞

步驟:

在 fixture 中增加@pytest.fixture(params=[1, 2, 3, ‘linda’])

在?法參數寫 request,方法體里面使用 request.param 接收參數

# @pytest.fixture(params=['tom', 'jenny'])
# def login(request):
#     print(f"用戶名:{request.param}")
#     return request.param
#
#
# def test_demo1(login):
#     print(f'demo1 case:數據為{login}')@pytest.fixture(params=[['tom', 'harry'], ['jenny', 'jack']])
def login(request):print(f"用戶名:{request.param}")return request.paramdef test_demo1(login):print(f'demo1 case:數據為{login}')

Fixture 的用法總結

  • 模擬 setup,teardown(一個用例可以引用多個 fixture)
  • yield 的用法
  • 作用域( session,module, 類級別,方法級別 )
  • 自動執行 (autouse 參數)
  • conftest.py 用法,一般會把 fixture 寫在 conftest.py 文件中(這個文件名字是固定的,不能改)
  • 實現參數化

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/35142.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/35142.shtml
英文地址,請注明出處:http://en.pswp.cn/news/35142.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

CMake 配置 Vulkan 出現鏈接失敗,找不到 vkEnumerateInstanceExtensionProperties 符號的錯誤的解決方法

使用 CMake 配置 glfw, glm 的時候,總是提示鏈接失敗,找不到 vkEnumerateInstanceExtensionProperties 符號 cmake_minimum_required(VERSION 3.4...3.27)if(${CMAKE_VERSION} VERSION_LESS 3.27)cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_…

UG NX二次開發(C#)-CAM-獲取刀具類型

文章目錄 1、前言2、UG NX中的刀具類型3、獲取刀具類型3.1 刀具類型幫助文檔1、前言 在UG NX的加工模塊,加工刀具是一個必要的因素,其包括了多種類型的類型,有銑刀、鉆刀、車刀、磨刀、成型刀等等,而且每種刀具所包含的信息也各不相同。想獲取刀具的信息,那就要知道刀具的…

2023最新水果編曲軟件FL Studio 21.1.0.3267音頻工作站電腦參考配置單及系統配置要求

音樂在人們心中的地位日益增高,近幾年音樂選秀的節目更是層出不窮,喜愛音樂,創作音樂的朋友們也是越來越多,音樂的類型有很多,好比古典,流行,搖滾等等。對新手友好程度基本上在首位,…

用Python畫多個圓圈代碼

編輯:2023-08-13 15:10 在Python中,我們可以使用turtle庫來繪制各種形狀,包括圓圈。這是一個相當基本的問題,但是對于新手程序員來說,它可能會很有用。在這篇文章中,我們將向你展示如何使用Python的turtle…

【報童模型】隨機優化問題二次規劃

面對需求的不確定性,報童模型是做庫存優化的常見模型。而標準報童模型假設價格是固定的,此時求解一個線性規劃問題,可以得到最優訂貨量,這種模型存在局限性。因為現實世界中價格與需求存在一定的關系,本文假設需求q是價…

LNMP環境介紹和搭建

一.LNMP簡介 1.含義 2.工作原理 二.部署LNMP環境 1.Nginx環境 (1)上傳nginx包,下載編譯安裝工具并解包到指定目錄(tar 參數 tar包 - C 目錄路徑) (2) 開始編譯安裝,每次編譯后…

nbcio-boot升級到3.1后出現online表單新增報錯

nbcio-boot升級springboot、mybatis-plus和JSQLParser后出現新增online表單的時候報錯,如下: 2023-08-13 21:18:01.292 [http-nio-8080-exec-12] [1;31mERROR[0;39m [36mo.jeecg.common.exception.JeecgBootExceptionHandler:69[0;39m - Handler dispat…

【JVM】JVM垃圾收集器

文章目錄 什么是JVM垃圾收集器四種垃圾收集器(按類型分)1.串行垃圾收集器(效率低)2.并行垃圾收集器(JDK8默認使用此垃圾回收器)3.CMS(并發)垃圾收集器(只針對老年代垃圾回收的)4.G1垃圾回收器(在…

設計模式之七:適配器模式與外觀模式

面向對象適配器將一個接口轉換成另一個接口,以符合客戶的期望。 // 用火雞來冒充一下鴨子class Duck { public:virtual void quack() 0;virtual void fly() 0; };class Turkey { public:virtual void gobble() 0;virtual void fly() 0; };class TurkeyAdapter :…

利用爬蟲爬取圖片并保存

1 問題 在工作中,有時會遇到需要相當多的圖片資源,可是如何才能在短時間內獲得大量的圖片資源呢? 2 方法 我們知道,網頁中每一張圖片都是一個連接,所以我們提出利用爬蟲爬取網頁圖片并下載保存下來。 首先通過網絡搜索…

Linux 1.2.13 -- IP分片重組源碼分析

Linux 1.2.13 -- IP分片重組源碼分析 引言為什么需要分片傳輸層是否存在分段操作IP分片重組源碼分析ip_createip_findip_frag_createip_doneip_glueip_freeip_expireip_defragip_rcv 總結 本文源碼解析參考: 深入理解TCP/IP協議的實現之ip分片重組 – 基于linux1.2.13 計網理論…

樹莓派RP2040 用Arduino IDE安裝和編譯

目錄 1 Arduino IDE 1.1 IDE下載 1.2 安裝 arduino mbed os rp2040 boards 2 編程-燒錄固件 2.1 打開點燈示例程序 2.2 選擇Raspberry Pi Pico開發板 2.3 編譯程序 2.4 燒錄程序 2.4.1 Raspberry Pi Pico開發板首次燒錄提示失敗 2.4.2 解決首次下載失敗問題 2.4.2.1…

curl 快速入門使用教程

你好,我是悅創。 curl 是一個強大的命令行工具,用于獲取或發送數據,包括 HTTP、HTTPS、FTP、FTPS、SCP、SFTP、TFTP、DICT、TELNET、LDAP 或 FILE 協議等。在本教程中,我們將主要介紹如何使用 curl 進行 HTTP/HTTPS 請求。 1. 安…

Java基礎五之for循環小練習

加油,新時代大工人! 一、Java基礎之算術運算符 二、Java基礎之類型轉換 三、Java基礎之【字符串操作以及自增自減操作】 四、Java基礎之賦值運算符和關系運算符 package base;import java.io.InputStream; import java.util.Scanner;/*** author wh* date 2023年08…

無涯教程-Perl - recv函數

描述 This function receives a message on SOCKET attempting to read LENGTH bytes, placing the data read into variable SCALAR.The FLAGS argument takes the same values as the recvfrom( ) system function, on which the function is based. When communicating wit…

論文淺嘗 | 面向多步推理任務專業化較小語言模型

筆記整理:張沈昱,東南大學碩士,研究方向為自然語言處理 鏈接:https://github.com/FranxYao/FlanT5-CoT-Specialization 動機 本文的動機是探索如何在多步推理任務中通過大型語言模型提升較小的語言模型的性能。作者認為&#xff0…

云開發超多功能工具箱組合微信小程序源碼/附帶流量主

介紹: 這是一款云開發超多功能工具箱組合微信小程序源碼附帶流量主功能,小程序內包含了40余個功能,堪稱全能工具箱了,大致功能如下: 證件照制作 | 垃圾分類查詢 | 個性簽名制作 二維碼生成丨文字九宮格 | 手持彈幕丨…

總結synchronized

一.synchronized的特性 synchronized 是 Java 語言中內置的關鍵字,用于實現線程同步,以確保多線程環境下共享資源的安全訪問。 互斥性:synchronized保證了同一時刻只有一個線程可以執行被synchronized修飾的代碼塊或方法。當一個線程進入sync…

使用GraphQL在Postman中進行API測試

GraphQL 是一種用于API的開源數據查詢和操作語言,用于API的查詢語言和運行時。它使客戶端能夠精確地指定其數據需求,并獲得預測性地結果。GraphQL旨在提高API的效率、靈活性和可靠性。 Postman 是一款用于API開發的強大工具,它支持REST和Gra…

LVS簡介及LVS-DR搭建

目錄 一. LVS簡介: 1.簡介 2. LVS工作模式: 3. LVS調度算法: 4. LVS-DR集群介紹: 二.LVS-DR搭建 1.RS配置 1)兩臺RS,需要下載好httpd軟件并準備好配置文件 2)添加虛擬IP(vip&…