Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get rid of defineSuite #8120

Merged
merged 1 commit into from
Sep 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
28 changes: 16 additions & 12 deletions Documentation/Contributors/TestingGuide/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ It is also possible for Karma to run all tests against each browser installed on

#### Run a Single Test or Suite

Sometimes it is useful to run a single test or suite for easier debugging purposes. To do this simply change the `it` function call for the desired test to `fit`, the `f` stands for `focused` in Jasmine speak. Likewise, to run an entire suite, use `fdefineSuite` instead of `defineSuite`.
Sometimes it is useful to run a single test or suite for easier debugging purposes. To do this simply change the `it` function call for the desired test to `fit`, the `f` stands for `focused` in Jasmine speak. Likewise, to run an entire suite, use `fdescribe` instead of `describe`.

## Testing Previous Versions of CesiumJS

Expand Down Expand Up @@ -233,22 +233,24 @@ Tests are written in JavaScript using Jasmine. It is important to realize that
Here is a stripped down version of the tests:

```javascript
defineSuite([
define([
'Core/Cartesian3'
], function(
Cartesian3) {
'use strict';

it('construct with default values', function() {
var cartesian = new Cartesian3();
expect(cartesian.x).toEqual(0.0);
expect(cartesian.y).toEqual(0.0);
expect(cartesian.z).toEqual(0.0);
describe('Cartesian3', function(){
it('construct with default values', function() {
var cartesian = new Cartesian3();
expect(cartesian.x).toEqual(0.0);
expect(cartesian.y).toEqual(0.0);
expect(cartesian.z).toEqual(0.0);
});
});
});
```

`defineSuite` identifies this file as a test suite and include modules the same way `define` is used in engine code. The modules are listed in alphabetical order as usual _except_ that the module being tested is listed first.
`describe` identifies this file as a test suite and we include modules the same way `define` is used in engine code.

Using Jasmine, each test is defined by calling `it` and passing a string that describes the test and a function that is the test.

Expand Down Expand Up @@ -692,17 +694,18 @@ This test is more cohesive and easier to debug than if it were written using a _

### Categories

As mentioned above, some tests are in the `'WebGL'` category. To assign a category to a suite, pass the category to `defineSuite`.
As mentioned above, some tests are in the `'WebGL'` category. To assign a category to a suite, pass the category to `describe`.

```javascript
defineSuite([
define([
'Scene/DebugModelMatrixPrimitive',
'Specs/createScene'
], function(
DebugModelMatrixPrimitive,
createScene) {
'use strict';

describe('Scene/DebugModelMatrixPrimitive', function(){
var scene;

beforeAll(function() {
Expand All @@ -716,9 +719,10 @@ defineSuite([
// ...

}, 'WebGL');
});
```

`defineSuite` is a custom CesiumJS function that wraps Jasmine define calls and provides the category capability.
CesiumJS uses a customized `describe` function that wraps Jasmine describe calls and provides the category capability.

## Manual Testing

Expand Down Expand Up @@ -756,7 +760,7 @@ You can run or debug the tests by using the first two buttons. The third button

![](webstorm-test-runner.png)

This runner has lots of options, such as only showing failing tests or automatically re-running the tests on a test interval (great for development when combined with `fdefineSuite`!). You can hover over each of the buttons to see what they do.
This runner has lots of options, such as only showing failing tests or automatically re-running the tests on a test interval (great for development when combined with `fdescribe`!). You can hover over each of the buttons to see what they do.

To make jumping between the source and spec files easier download the [Cesium WebStorm plugin](https://github.com/AnalyticalGraphicsInc/cesium-webstorm-plugin).

Expand Down
3 changes: 0 additions & 3 deletions Specs/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
"env": {
"jasmine": true
},
"globals": {
"defineSuite": true
},
"rules": {
"no-self-assign": "off"
}
Expand Down
25 changes: 14 additions & 11 deletions Specs/Core/ApproximateTerrainHeightsSpec.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
defineSuite([
'Core/ApproximateTerrainHeights',
'Core/Cartesian3',
'Core/Math',
'Core/Rectangle'
], function(
ApproximateTerrainHeights,
Cartesian3,
CesiumMath,
Rectangle) {
'use strict';
define([
'Core/ApproximateTerrainHeights',
'Core/Cartesian3',
'Core/Math',
'Core/Rectangle'
], function(
ApproximateTerrainHeights,
Cartesian3,
CesiumMath,
Rectangle) {
'use strict';

describe('Core/ApproximateTerrainHeights', function() {

beforeAll(function() {
return ApproximateTerrainHeights.initialize();
Expand Down Expand Up @@ -68,3 +70,4 @@ defineSuite([
ApproximateTerrainHeights._terrainHeights = heights;
});
});
});
57 changes: 30 additions & 27 deletions Specs/Core/ArcGISTiledElevationTerrainProviderSpec.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,32 @@
defineSuite([
'Core/ArcGISTiledElevationTerrainProvider',
'Core/DefaultProxy',
'Core/GeographicTilingScheme',
'Core/HeightmapTerrainData',
'Core/Math',
'Core/Request',
'Core/RequestScheduler',
'Core/Resource',
'Core/RuntimeError',
'Core/TerrainProvider',
'Core/WebMercatorTilingScheme',
'Specs/pollToPromise'
], function(
ArcGISTiledElevationTerrainProvider,
DefaultProxy,
GeographicTilingScheme,
HeightmapTerrainData,
CesiumMath,
Request,
RequestScheduler,
Resource,
RuntimeError,
TerrainProvider,
WebMercatorTilingScheme,
pollToPromise) {
'use strict';
define([
'Core/ArcGISTiledElevationTerrainProvider',
'Core/DefaultProxy',
'Core/GeographicTilingScheme',
'Core/HeightmapTerrainData',
'Core/Math',
'Core/Request',
'Core/RequestScheduler',
'Core/Resource',
'Core/RuntimeError',
'Core/TerrainProvider',
'Core/WebMercatorTilingScheme',
'Specs/pollToPromise'
], function(
ArcGISTiledElevationTerrainProvider,
DefaultProxy,
GeographicTilingScheme,
HeightmapTerrainData,
CesiumMath,
Request,
RequestScheduler,
Resource,
RuntimeError,
TerrainProvider,
WebMercatorTilingScheme,
pollToPromise) {
'use strict';

describe('Core/ArcGISTiledElevationTerrainProvider', function() {

var lercTileUrl = 'Data/Images/Red16x16.png';
var availability;
Expand Down Expand Up @@ -476,3 +478,4 @@ describe('requestTileGeometry', function() {
});
});
});
});
7 changes: 5 additions & 2 deletions Specs/Core/AssociativeArraySpec.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
defineSuite([
define([
'Core/AssociativeArray'
], function(
AssociativeArray) {
'use strict';
'use strict';

describe('Core/AssociativeArray', function() {

it('constructor has expected default values', function() {
var associativeArray = new AssociativeArray();
Expand Down Expand Up @@ -76,3 +78,4 @@ defineSuite([
expect(associativeArray.remove(undefined)).toBe(false);
});
});
});
7 changes: 5 additions & 2 deletions Specs/Core/AttributeCompressionSpec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
defineSuite([
define([
'Core/AttributeCompression',
'Core/Cartesian2',
'Core/Cartesian3',
Expand All @@ -12,7 +12,9 @@ defineSuite([
Cartesian4,
defined,
CesiumMath) {
'use strict';
'use strict';

describe('Core/AttributeCompression', function() {

var negativeUnitZ = new Cartesian3(0.0, 0.0, -1.0);
it('oct decode(0, 0)', function() {
Expand Down Expand Up @@ -742,3 +744,4 @@ defineSuite([
}).toThrowDeveloperError();
});
});
});
7 changes: 5 additions & 2 deletions Specs/Core/AxisAlignedBoundingBoxSpec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
defineSuite([
define([
'Core/AxisAlignedBoundingBox',
'Core/Cartesian3',
'Core/Intersect',
Expand All @@ -8,7 +8,9 @@ defineSuite([
Cartesian3,
Intersect,
Plane) {
'use strict';
'use strict';

describe('Core/AxisAlignedBoundingBox', function() {

var positions = [
new Cartesian3(3, -1, -3),
Expand Down Expand Up @@ -162,3 +164,4 @@ defineSuite([
}).toThrowDeveloperError();
});
});
});
7 changes: 5 additions & 2 deletions Specs/Core/BingMapsApiSpec.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
defineSuite([
define([
'Core/BingMapsApi'
], function(
BingMapsApi) {
'use strict';
'use strict';

describe('Core/BingMapsApi', function() {

it('getKey returns provided key if one is provided', function() {
expect(BingMapsApi.getKey('foo')).toEqual('foo');
Expand All @@ -15,3 +17,4 @@ defineSuite([
BingMapsApi.defaultKey = oldKey;
});
});
});
7 changes: 5 additions & 2 deletions Specs/Core/BingMapsGeocoderServiceSpec.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
defineSuite([
define([
'Core/BingMapsGeocoderService',
'Core/Rectangle',
'Core/Resource'
], function(
BingMapsGeocoderService,
Rectangle,
Resource) {
'use strict';
'use strict';

describe('Core/BingMapsGeocoderService', function() {

afterAll(function() {
Resource._Implementations.loadAndExecuteScript = Resource._DefaultImplementations.loadAndExecuteScript;
Expand Down Expand Up @@ -66,3 +68,4 @@ defineSuite([
});
});
});
});
7 changes: 5 additions & 2 deletions Specs/Core/BoundingRectangleSpec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
defineSuite([
define([
'Core/BoundingRectangle',
'Core/Cartesian2',
'Core/Ellipsoid',
Expand All @@ -14,7 +14,9 @@ defineSuite([
Intersect,
Rectangle,
createPackableSpecs) {
'use strict';
'use strict';

describe('Core/BoundingRectangle', function() {

it('default constructor sets expected values', function() {
var rectangle = new BoundingRectangle();
Expand Down Expand Up @@ -257,3 +259,4 @@ defineSuite([

createPackableSpecs(BoundingRectangle, new BoundingRectangle(1, 2, 3, 4), [1, 2, 3, 4]);
});
});
7 changes: 5 additions & 2 deletions Specs/Core/BoundingSphereSpec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
defineSuite([
define([
'Core/BoundingSphere',
'Core/Cartesian3',
'Core/Cartographic',
Expand Down Expand Up @@ -28,7 +28,9 @@ defineSuite([
Plane,
Rectangle,
createPackableSpecs) {
'use strict';
'use strict';

describe('Core/BoundingSphere', function() {

var positionsRadius = 1.0;
var positionsCenter = new Cartesian3(10000001.0, 0.0, 0.0);
Expand Down Expand Up @@ -915,3 +917,4 @@ defineSuite([

createPackableSpecs(BoundingSphere, new BoundingSphere(new Cartesian3(1.0, 2.0, 3.0), 4.0), [1.0, 2.0, 3.0, 4.0]);
});
});
7 changes: 5 additions & 2 deletions Specs/Core/BoxGeometrySpec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
defineSuite([
define([
'Core/BoxGeometry',
'Core/arrayFill',
'Core/AxisAlignedBoundingBox',
Expand All @@ -14,7 +14,9 @@ defineSuite([
GeometryOffsetAttribute,
VertexFormat,
createPackableSpecs) {
'use strict';
'use strict';

describe('Core/BoxGeometry', function() {

it('constructor throws without maximum corner', function() {
expect(function() {
Expand Down Expand Up @@ -140,3 +142,4 @@ defineSuite([
vertexFormat : VertexFormat.POSITION_AND_NORMAL
}), [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, -1.0]);
});
});
7 changes: 5 additions & 2 deletions Specs/Core/BoxOutlineGeometrySpec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
defineSuite([
define([
'Core/BoxOutlineGeometry',
'Core/arrayFill',
'Core/AxisAlignedBoundingBox',
Expand All @@ -12,7 +12,9 @@ defineSuite([
Cartesian3,
GeometryOffsetAttribute,
createPackableSpecs) {
'use strict';
'use strict';

describe('Core/BoxOutlineGeometry', function() {

it('constructor throws without maximum corner', function() {
expect(function() {
Expand Down Expand Up @@ -110,3 +112,4 @@ defineSuite([
maximum : new Cartesian3(4.0, 5.0, 6.0)
}), [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, -1.0]);
});
});
Loading