Skip to content

Commit

Permalink
Merge pull request #34 from georgejecook/feature/multiExpect
Browse files Browse the repository at this point in the history
Feature/multi expect
  • Loading branch information
georgejecook authored Mar 21, 2019
2 parents 6df6188 + ee85712 commit 498ca5c
Show file tree
Hide file tree
Showing 9 changed files with 488 additions and 224 deletions.
39 changes: 38 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,43 @@
# Rooibos CHANGELOG

## 0.2.0 Initial feedback relase
## 2.1.0

### Added
- Multiple overloads for expectOnce, allowing for easy definition of multi params and return values from the same method invocation

### Changed

### Deprecated

### Removed

### Fixed

- Potential crash when passing wrong type of arg value into a fake

## 2.0.0

### Added

- Leverage rooibosC preprocessor
- Better examples
- Faster parsing

### Changed

- Now requires rooibosC to create the test metadata structures

### Deprecated

### Removed

- Legacy framework support

### Fixed

- various runtime error scenarios

## 0.2.0 Initial feedback release
- Compatability with Roku unit test framework
- Fix issues submitted by initial users
- Add `'@OnlyParams` tag
Expand Down
10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
<h3 align="center">
Simple, mocha-inspired, flexible, fun Brightscript test framework for ROKU apps
</h3>
<p align="center">
Version 2.0.0
</p>
<p align="center">
<img src="images/exampleImage.png" alt="Mocha test framework" />
</p>
Expand All @@ -18,10 +15,10 @@ Simple, mocha-inspired, flexible, fun Brightscript test framework for ROKU apps
- **[Youtube training videos](https://www.youtube.com/playlist?list=PLJRLV4QDx83vsYMD9bIs-cjoDXmNmO8Jv)**
- **[Documentation](docs/index.md)**
- **[API Documentaiton](https://georgejecook.github.io/rooibos)**
- **[Release notes / History / Changes](CHANGELOG.md)**
- **[CHANGELOG](CHANGELOG.md)**
- **[VSCode snippets](docs/vsCodeSnippets.md)**
- [Roku dev forum topic](https://forums.roku.com/viewforum.php?f=34)
- [Roku developer slack group](https://join.slack.com/t/rokudevelopers/shared_invite/enQtMzgyODg0ODY0NDM5LTc2ZDdhZWI2MDBmYjcwYTk5MmE1MTYwMTA2NGVjZmJiNWM4ZWY2MjY1MDY0MmViNmQ1ZWRmMWUzYTVhNzJiY2M)
- \#roku channel on the [roku developer's slack](https://join.slack.com/t/rokudevelopers/shared_invite/enQtMzgyODg0ODY0NDM5LTc2ZDdhZWI2MDBmYjcwYTk5MmE1MTYwMTA2NGVjZmJiNWM4ZWY2MjY1MDY0MmViNmQ1ZWRmMWUzYTVhNzJiY2M)
- [Issue tracker](https://github.com/georgejecook/rooibos/issues)
- [Roadmap](ROADMAP.md)

Expand All @@ -40,7 +37,8 @@ Also thanks to the guys who made and maintain [mochaJs](https://mochajs.org/), o
## FAQ
### Is Rooibos ready for production use?

Rooibos has so far been used on a couple of production projects, running CI with over 1500 tests between them. It does however, use the same test running mechanism of the official roku unit testing framework, which has been in circulation for several years.
Rooibos is the test framework used by several of my clients, running CI with over 3000 tests between them. It started life as rewrite of the official roku unit testing framework, which has been in circulation for several years.


### Is Rooibos actively maintained?

Expand Down
33 changes: 9 additions & 24 deletions ROADMAP.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,8 @@
# Rooibos roadmap
# Rooibos Roadmap

Up to date as of Feb 4th, 2019
## ShortTerm

## 0.1.0 Initial release [RELEASED]

## 0.2.0 Initial feedback [RELEASED]

Fix immediate issues that come back from the first few weeks of release
Also add an `'@OnlyParams[p1,...p6]` tag, so that we
don't need to use `@IgnoreParams`

## 0.3.0 rooibosC (beta) - remove eval from rooibos [RELEASED]

eval is no longer supported by roku. I don't want rooibos to lose it's accesible annotation style test writing. I've therefore created a preprocessor (named rooibosC) which creates a rooibos.function.map.brs.


## 2.0.0 Move ALL test parsing to rooibosC [RELEASED]

It's so much quicker to parse in js, that I will rewrite the core parser, to spit out prebaked json, which can be loaded at runtime, to greatly increase rooibos's performance.

## 2.0.x Unit tests for the framework
### Unit tests for the framework and general framework improvements

Unit tests will be written which test the following:

Expand All @@ -30,12 +13,14 @@ Unit tests will be written which test the following:
- Stubs
- Expect

# MidTerm

## 2.1.0 Add additional reporting opptions
### Add additional reporting options

Will add the ability to specifiy a unit test reporting class, to faciliate custom unit test reporting
Will add the ability to specify a unit test reporting class, to facilitate custom unit test reporting

## 2.2.0 Integration with [To be named] roku pre-processor
# LongTerm

I have another project in the works which pre-processes brightscript and xml to provide an Adobe flex-like syntax for easy MVVM roku development. I want to integrate hooks into that, which will automatically generate node test files.
### Integrate with vscode ide

Support test execution from and output to Visual Studio Code ide, as per mocha test runner extension
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.0
2.1.0
20 changes: 17 additions & 3 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ function LoadDetails() as void
end function
```

We can use a mock, to facilitate testing against the network layer
We can use a stub, to facilitate testing against the network layer

```
detailsVM = CreateDetailsVM()
Expand All @@ -572,15 +572,15 @@ m.AssertFalse(detailsVM.isLoading)
m.AssertTure(detailsVM.isShowingError)
```

In this case, our detailsVM object, wil
In this case, our detailsVM object, will not actually call ExecuteNetRequests's source code; but will instead call a _fake_ (i.e fake method body), which can return predtermined values, or be later checked for invocation arg conformance.

#### Mocks
Mocks are _expected_ fakes. Your code will invoke the method, as if it _is_ the real method; but the difference is that Rooibos will track the invoction of mocks, and if the method was not invoked in the manner you expected (i.e. with the expected parameters and the expected number of invocations) then a unit test failure will result.

We create mocks by using the methods:

- Expect - Creates a generic mock
- ExpectOnce - Creates a mock, which we expect to be called once
- ExpectOnce - Creates a mock, which we expect to be called once _or can created individual overloaded calls to the same method_
- ExpectNone - Creates a mock, which we _never_ expect to be invoked

### Asserting mocks
Expand Down Expand Up @@ -627,6 +627,20 @@ You can save yourself a lot of time, and really think about and kick the tyres o

Up to 9 arguments are supported.

#### Expecting several calls to the same method, with verified invocation params

You may wish to call the same method various times, and return different values, or check different arguments were invoked

In this case, we use overloaded `expectOnce` calls, as per the following example:

```
m.expectOnce(obj, "mockMethod", [arg1], result1, true)
m.expectOnce(obj, "mockMethod", [arg2], result2, true)
m.expectOnce(obj, "mockMethod", [arg3], result3, true)
```

This will now set the framework to expect 3 calls to mockMethod, the first with value of _arg1_, returning _result1_; the second with value of _arg2_, returning _result2_; and the last with value of _arg3_, returning _result3_


#### Specifying an expected value of invalid, with m.invalidValue

Expand Down
Loading

0 comments on commit 498ca5c

Please sign in to comment.