在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:onsi/ginkgo开源软件地址:https://github.com/onsi/ginkgo开源编程语言:Go 100.0%开源软件介绍:Ginkgo 2.0 is now Generally Available!You can learn more about 2.0 in the Migration Guide! Ginkgo is a mature testing framework for Go designed to help you write expressive specs. Ginkgo builds on top of Go's import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
...
)
Describe("Checking books out of the library", Label("library"), func() {
var library *libraries.Library
var book *books.Book
var valjean *users.User
BeforeEach(func() {
library = libraries.NewClient()
book = &books.Book{
Title: "Les Miserables",
Author: "Victor Hugo",
}
valjean = users.NewUser("Jean Valjean")
})
When("the library has the book in question", func() {
BeforeEach(func() {
Expect(library.Store(book)).To(Succeed())
})
Context("and the book is available", func() {
It("lends it to the reader", func() {
Expect(valjean.Checkout(library, "Les Miserables")).To(Succeed())
Expect(valjean.Books()).To(ContainElement(book))
Expect(library.UserWithBook(book)).To(Equal(valjean))
})
})
Context("but the book has already been checked out", func() {
var javert *users.User
BeforeEach(func() {
javert = users.NewUser("Javert")
Expect(javert.Checkout(library, "Les Miserables")).To(Succeed())
})
It("tells the user", func() {
err := valjean.Checkout(library, "Les Miserables")
Expect(error).To(MatchError("Les Miserables is currently checked out"))
})
It("lets the user place a hold and get notified later", func() {
Expect(valjean.Hold(library, "Les Miserables")).To(Succeed())
Expect(valjean.Holds()).To(ContainElement(book))
By("when Javert returns the book")
Expect(javert.Return(library, book)).To(Succeed())
By("it eventually informs Valjean")
notification := "Les Miserables is ready for pick up"
Eventually(valjean.Notifications).Should(ContainElement(notification))
Expect(valjean.Checkout(library, "Les Miserables")).To(Succeed())
Expect(valjean.Books()).To(ContainElement(book))
Expect(valjean.Holds()).To(BeEmpty())
})
})
})
When("the library does not have the book in question", func() {
It("tells the reader the book is unavailable", func() {
err := valjean.Checkout(library, "Les Miserables")
Expect(error).To(MatchError("Les Miserables is not in the library catalog"))
})
})
}) Jump to the docs to learn more. It's easy to bootstrap and start writing your first specs. If you have a question, comment, bug report, feature request, etc. please open a GitHub issue, or visit the Ginkgo Slack channel. CapabilitiesWhether writing basic unit specs, complex integration specs, or even performance specs - Ginkgo gives you an expressive Domain-Specific Language (DSL) that will be familiar to users coming from frameworks such as Quick, RSpec, Jasmine, and Busted. This style of testing is sometimes referred to as "Behavior-Driven Development" (BDD) though Ginkgo's utility extends beyond acceptance-level testing. With Ginkgo's DSL you can use nestable At runtime, Ginkgo can run your specs in reproducibly random order and has sophisticated support for spec parallelization. In fact, running specs in parallel is as easy as ginkgo -p By following established patterns for writing parallel specs you can build even large, complex integration suites that parallelize cleanly and run performantly. As your suites grow Ginkgo helps you keep your specs organized with labels and lets you easily run subsets of specs, either programmatically or on the command line. And Ginkgo's reporting infrastructure generates machine-readable output in a variety of formats and allows you to build your own custom reporting infrastructure. Ginkgo ships with And that's just Ginkgo! Gomega brings a rich, mature, family of assertions and matchers to your suites. With Gomega you can easily mix synchronous and asynchronous assertions in your specs. You can even build your own set of expressive domain-specific matchers quickly and easily by composing Gomega's existing building blocks. Happy Testing! LicenseGinkgo is MIT-Licensed ContributingSee CONTRIBUTING.md |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论