railsware/Sleipnir là dự án mã nguồn mở trên GitHub với 840 sao.
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.
Sleipnir is a BDD-style framework for Swift. Sleipnir is highly inspired by Cedar.
Also
In Norse mythology, Sleipnir is Odin's steed, is the child of Loki and Svaðilfari, is described as the best of all horses, and is sometimes ridden to the location of Hel.
class SampleSpec : SleipnirSpec {
var spec : () = describe("Horse") {
context("usual") {
it("is not awesome") {
let usualHorse = UsualHorse()
usualHorse.legsCount.should.equal(4)
expect(usualHorse.isAwesome()).to(beFalse())
}
}
context("Sleipnir") {
it("is awesome") {
let sleipnirHorse = Sleipnir()
sleipnirHorse.legsCount.should.equal(8)
expect(sleipnirHorse.isAwesome()).to(beTrue())
}
}
}
}
Core principles
Sleipnir is not dependent of NSObject, it is pure Swift BDD testing framework
Sleipnir is not using XCTest
Sleipnir has nice command line output and support for custom test reporters
Other features, like seeded random tests invocation, focused and excluded examples/groups, etc.
Installation
Manually (preferred way)
Add Sleipnir as a submodule: git submodule add https://github.com/railsware/sleipnir ThirdParty/Sleipnir
Drag'n'drop Sleipnir.xcodeproj to your test target
In order to run your specs you should invoke Runner.run() from the main.swift of your test target.
The default test runner will produce the following command line output, indicating all the failures and some meta information about each failure:
Running With Random Seed: 1234
.....F..
FAILURE Some spec should pass:
/Path/To/Your/Specs/TestSpec.swift:16 Expected <1> to equal <2>
Finished in 0.0075 seconds
8 examples, 1 failures
Seeded random specs run
All examples would run in random order with the random seed specified in output. If you would like to re-run tests in the same order you should pass a seed to run() method:
Runner.run(seed: 1234)
Examples and ExampleGroups
ExampleGroups are created with describe or context keywords.
Within the block passed to ExampleGroup you can declare examples using the it keyword.
ExampleGroups can be nested in order to create clean structure of your tests.
Under the hood describe method creates an instance of ExampleGroup and evaluates the block passed to it. Blocks passed to examples are evaluated dynamically during the test execution.
Setup/Teardown code
Sleipnir supports some hooks to execute before or after examples. This allows to share some setup/teardown code between examples.
beforeEach block will be executed before each example in the current group and all nested groups.
afterEach block will be executed after each example.
You can also specify global setup/teardown blocks using beforeAll and afterAll keywords.
They will run once before or after all examples in the current group and all the nested groups.
Focused and excluded specs
You can specify examples and example groups to be focused by placing f letter before declaration: fdescribe, fcontext, fit. In this case the spec runner will only run focused examples/example groups and ignore all the others.
You can also mark an example or example group as pending. It won't run but will be printed along with the test results.
To mark something as pending add an x letter before declaration: xdescribe, xcontext, xit.
Example can also be marked as pending by passing PENDING instead of spec block:
it("is pending", PENDING)
Shared example groups
Sleipnir supports extracting common specs through shared example groups.
They can include any number of it, context, describe, before and after blocks.
You can pass example-specific state into the shared example group through sharedContext dictionary.
var nonNilObject : () =
sharedExamplesFor("a non-nil object") { (sharedContext : SharedContext) in
var object: AnyObject?
beforeEach {
object = sharedContext()["object"]
}
it("should not be nil") {
expect(object).toNot(beNil())
}
}
var spec : () = context("A non-nil object") {
let someObject: String = "Some Object"
itShouldBehaveLike("a non-nil object", { ["object" : someObject] })
}
If you don't need any context, you can use closures without parameters:
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/railsware/Sleipnir là nguồn chính thức.
railsware/Sleipnir có bao nhiêu sao?
railsware/Sleipnir có 840 sao GitHub — tải lại trang để xem số mới nhất, hoặc xem trực tiếp github.com/railsware/Sleipnir. TopGit phản chiếu số sao của GitHub nhưng không cam kết đến từng phút.
railsware/Sleipnir có phải mã nguồn mở không?
TopGit chưa ghi nhận license cho railsware/Sleipnir. Phần lớn repo public trên GitHub là mã nguồn mở, nhưng điều khoản khác nhau từng repo — mở file LICENSE để xác nhận.
railsware/Sleipnir còn được duy trì không?
TopGit chưa ghi nhận lần push gần đây của railsware/Sleipnir. Xem lịch sử commit trực tiếp trên GitHub để biết thông tin chính xác nhất.
railsware/Sleipnir là gì?
railsware/Sleipnir (railsware/Sleipnir) là dự án đa ngôn ngữ TopGit theo dõi. Tính tới lần đồng bộ gần nhất, repo có 840 sao.
railsware/Sleipnir viết bằng ngôn ngữ gì?
Dữ liệu TopGit chưa ghi nhận ngôn ngữ chính cho railsware/Sleipnir. Xem danh sách file trên GitHub để biết chi tiết.
Đọc đầy đủ README ở tab phía trên.
Muốn nghe thêm một ý kiến về Sleipnir?
Hỏi một AI đọc được trang này — một cú bấm là có ngay nhận định về Sleipnir.