airspec: Allow reusing test specs
See original GitHub issueTo reuse test functions, we can use the return value of test method like this:
Idea A
class Fixture[A](data:Seq[A]) extends AirSpec {
def test1: Unit = { data shouldNotBe empty }
def test2: Unit = { data.length shouldBe data.size }
}
class MyTest extends AirSpec {
def testIntSeq: AirSpec = new Fixture(Seq(1, 2, 3)) // Run the returned spec
def testStringSeq: AirSpec = new Fixture(Seq("a", "b")) // Run the returned spec
}
If Seq[AirSpec]
is returned, it should run this sequence of test specs.
idea B Another approach is passing a test context through DI, then allow running new AirSpec:
def test(context:Context): Unit = {
context.run(new Fixture(Seq(1, 2, 3))
context.run(new Fixture(Seq("a", "b"))
}
- It seems idea B is more straightforward
- Technically speaking, B is better since we can get a Surface of Fixture using
def run[A <: AirSpec](newSpec:A)
to get a list of test methods.
Issue Analytics
- State:
- Created 4 years ago
- Comments:12 (12 by maintainers)
Top Results From Across the Web
AirSpec: Testing Framework · Airframe - wvlet.github.io
If test specs returns Future values, AirSpec awaits the completion of async tests, so you don't need to write synchronization steps in your...
Read more >AirSpec: Writing Tests As Plain Functions In Scala - Medium
AirSpec uses pure Scala functions for writing test cases. ... Nesting and reusing test cases with context.run(spec); Handy keyword search ...
Read more >An open platform for Aerosol InfraRed Spectroscopy analysis
AIRSpec is a platform consisting of several chemometric packages developed for analysis of Fourier transform infrared (FTIR) spectra of ...
Read more >iPad Air - Technical Specifications - Apple
Size and Weight. 9.74 inches (247.6 mm) 7.02 inches (178.5 mm) 0.24 inch (6.1 mm). Wi-Fi models. 1.02 pounds (461 grams). Wi-Fi +...
Read more >Elvex® AirSpecs™ Black Stainless Steel Mesh Goggles, 12 ...
The Elvex® AirSpecs ™ with stainless steel mesh 'lens" are designed to protect the eye socket from pokes and prods of stationary or...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks for your explanation. Now I get fully understanding! Finally, I prefer B for its flexibility 😃
Done in #602