Giter VIP home page Giter VIP logo

sspec's People

sspec's Issues

New interface: using global functions

After all we'd better use global functions:

  • describe which calls SSMatcher.describe behind the scenes
  • context (same as describe)
  • it which calls SSMatcher.it behind the scenes
  • expect which calls SSMatcher.expect behind the scenes

There are a lot of checks we should be performing in order not to stack in some undesirable state:

  1. describe/context can be called only when current session is present
  2. it can be called only within describe/context
  3. expect can be called only within it

We will need to monitor type of "currentNode" during initialization and report failures when requirements not met.

Focused tests

We should be able to run focused tests.

From tester perspective it looks like:

fdescribe("Focused group")
fcontext("Focused context")
fit("Focused example")

Internally Node should have property focused: Bool = false, which could be turned to true with makeFocused() method.

When we run initialization, we create list of all registered examples. Examples under focused parent are also considered focused.

During test run we skip unfocused examples.

New progress reporter

Currently we display all running examples with their titles.

We can make alternative reporter which will display green/yellow/red dots for examples.

Global runner

We need one "runner" for all test functions:

import XCTest
import SSpec

class BDDTests: XCTestCase {
  func testBDD() {
    SSpec_run {
      myTestFunction1()
      myTestFunction2()
      myTestFunction3()
    }
  }

  static var allTests = [
    ("testBDD", testBDD),
  ]
}

Attempt to run two SSpec_runs should be reported as error.

We don't need Node.level property

The only place we use Node's level property is spec reporter.

We actually don't need it: level can be calculated in the reporter itself. Or even inferred from parent hierarchy.

Message formatting

We can improve error & example descriptions by supporting bold by inserting it in backquotes: `bold`.

Extensions of SSExpect not possible

We should be able to add extensions to SSExpect from outside packages:

extension SSExpect where T == MyCustomClas {
  public var beCPU: Void {
    assert(value.isCorrect,        // ERROR: value not visible
           error: "\(valueStr)")   // ERROR: valueStr not visible
  }
}

Also:

  • toString not visible.
  • negate variable should be accessible too.

Error reporting

Currently there's no error reporting on failures: we just have false flag for the given run.

The mechanism used should be easily extensible.

Avoid globals

Globals are still problem.

Let's hide them behind SSpec and if we need global function, do it explicitly:

let describe = SSpec.describe
// ...

Another alternative would be to have "test class":

class MyTestClass: SSpecTest {
  func test1() {
    describe() {
      // ...
    }
  }
}

But it looks too verbose.

Array comparison

If we try to compare two arrays, it will fail on compile time:

expect([1, 2]).to.eq([1,2])
// error: generic parameter 'T' could not be inferred

We need to fix this and also introduce new matchers for arrays:

  • eq -- for exact matching;
  • includes -- all elements of the parameter array are included in the matching array;
  • same -- both arrays have same elements (possibly with different order).

Before/After triggers

before function should be run before all examples:

var a = 0

before {
  a = 100
}

it {
  // modifies a
  a = 200
}

it {
  print(a) // prints 100
}

Also we need after function to clean-up data.

Prepare release script

We need release script which can:

  1. Upgrade the version
  2. Ask for "What's new" to append to changes log
  3. Push and merge commit on github

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.