matryer/silk — công cụ cho lập trình viên — đang có 939 sao GitHub trong nhóm Developer Tools. Markdown based document-driven RESTful API testing.
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
Adding parameters to the path (like GET /path?q=something) can be tricky, especially when you consider escaping etc. To address this, Silk supports parameters like lists:
* ?param=value
The parameters will be correctly added to the URL path before the request is made.
Cookies
Setting cookies on a request can be done using the HTTP header pattern:
* Cookie: "key=value"
See asserting cookies.
Assertions
Following the --- separator, you can specify assertions about the response. At a minimum, it is recommended that you assert the status code to ensure the request succeeded:
* Status: 200
You may also specify response headers in the same format as request headers:
If any of the headers do not match, the test will fail.
Capturing data
Silk allows you to capture values at the point of asserting them and reuse them in future requests and assertions. To capture a value, include a comment on the line that mentions a {placeholder}:
* Data.UserID: /.*/ // The user's unique {id}.
The value from UserID (e.g. 123) will be stored in a variable called id, and you can refer to it later:
## GET /users/{id}
The above would be a request to GET /users/123.
Captured values are only available when assertions are successful
Environment variables
You can access environment variables inside Silk tests using the {$NAME} format, where NAME is the environment name.
Asserting cookies
To assert that a cookie is present in a response, make a regex assertion against the Set-Cookie HTTP header:
* Set-Cookie: /key=value/
All cookie strings are present in a single Set-Cookie seperated by a pipe character.
Validating data
You can optionally include a verbatim body using code blocks surrounded by three back tics. If the response body does not exactly match, the test will fail:
```
Hello world!
```
You can flag expected response bodies as json directly after the three back tics.
This will assert that the actual response contains the same value for each expected key (recursively)
allowing for differences in whitespace and ordering as well as being lenient towards additional (unexpected) keys in the response.
You can use the flag json(strict) to enforce that no additional fields may be present while still allowing for differences in whitespace and key order.
You may also make any number of regex assertions against the body using the Body object:
* Body: /Hello world/
* Body: /This should be found too/
* Body: /and this/
Alternatively, you can specify a list (using *) of data fields to assert accessible via the Data object:
NOTE: Currenly this feature is only supported for JSON APIs.
Regex
Values may be regex, if they begin and end with a forward slash: /. The assertion will pass if the value (after being turned into a string) matches the regex.
The silk command runs tests against an HTTP endpoint.
Usage:
silk -silk.url="{endpoint}" {testfiles...}
{endpoint} the endpoint URL (e.g. http://localhost:8080)
{testfiles} list of test files (e.g. ./testfiles/one.silk.md ./testfiles/two.silk.md)
Notes:
Omit trailing slash from endpoint
{testfiles} can include a pattern (e.g. /path/*.silk.md) as this is expended by most terminals to a list of matching files
Golang
Silk is written in Go and integrates seamlessly into existing testing tools and frameworks. Import the runner package and use RunGlob to match many test files:
package project_test
import (
"testing"
"github.com/matryer/silk/runner"
)
func TestAPIEndpoint(t *testing.T) {
// start a server
s := httptest.NewServer(yourHandler)
defer s.Close()
// run all test files
runner.New(t, s.URL).RunGlob(filepath.Glob("../testfiles/failure/*.silk.md"))
}
See the documentation for the silk/runner package
Credit
Special thanks to @dahernan for his contributions and criticisms of Silk
matryer/silk thuộc nhóm Developer Tools trên TopGit, cùng 2 topic GitHub. Trang Trending và Topics liệt kê các repo cùng số sao và cùng ngôn ngữ để so sánh.
Đọc thêm về matryer/silk ở đâu?
Trang TopGit này là một snapshot — tab "Readme" hiển thị nguyên văn README của repo (đã bỏ link, giữ ảnh). Repo GitHub ở github.com/matryer/silk là nguồn chính thức.
matryer/silk có phải mã nguồn mở không?
Có — matryer/silk phát hành theo license GPL-2.0, nghĩa là mã nguồn mở để đọc, fork và (tùy license) tái sử dụng. Mã: github.com/matryer/silk.
matryer/silk có trang demo không?
Dự án có trang chủ ở http://silktest.org/. Tab "Readme" ở trang này thường có ảnh chụp và hướng dẫn bắt đầu nhanh.
matryer/silk dùng license gì?
matryer/silk phát hành theo license GPL-2.0. Nên mở file LICENSE trên GitHub để xác nhận — license metadata đôi khi lệch với thực tế dự án.
matryer/silk là gì?
matryer/silk (matryer/silk) là dự án Go trên GitHub. Theo mô tả gốc: Markdown based document-driven RESTful API testing.
Vì sao matryer/silk được xếp vào nhóm Developer Tools?
TopGit xếp matryer/silk vào nhóm Developer Tools dựa trên GitHub topics và mô tả của repo (gắn thẻ: "assertions", "testing"). Việc phân loại dựa trên metadata thật của repo, không phải đoán theo cảm tính biên tập.
Đọc đầy đủ README ở tab phía trên.
Vẫn đang phân vân về silk?
Một cú bấm sẽ gửi câu hỏi kèm trang này cho AI — xem AI nói gì về silk.