question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

airspec: Allow reusing test specs

See original GitHub issue

To 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:closed
  • Created 4 years ago
  • Comments:12 (12 by maintainers)

github_iconTop GitHub Comments

1reaction
takezoecommented, Aug 15, 2019

Thanks for your explanation. Now I get fully understanding! Finally, I prefer B for its flexibility 😃

0reactions
xerialcommented, Aug 15, 2019

Done in #602

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found