automutate-tests
Advanced tools
Comparing version 0.2.3 to 0.3.0
@@ -1,4 +0,3 @@ | ||
export * from "./autoMutatorFactory"; | ||
export * from "./hierarchyCrawler"; | ||
export * from "./testCase"; | ||
export * from "./testsFactory"; |
@@ -6,3 +6,2 @@ "use strict"; | ||
exports.__esModule = true; | ||
__export(require("./autoMutatorFactory")); | ||
__export(require("./hierarchyCrawler")); | ||
@@ -9,0 +8,0 @@ __export(require("./testCase")); |
@@ -1,2 +0,2 @@ | ||
import { AutoMutatorFactory } from "./autoMutatorFactory"; | ||
import { IMutationsProviderFactory } from "./mutationsProviderFactory"; | ||
/** | ||
@@ -31,5 +31,5 @@ * File names and settings for test cases. | ||
* @param settings Settings for the test case. | ||
* @param autoMutatorFactory Generates AutoMutator instances for testing. | ||
* @param autoMutatorFactory Creates mutation providers for files. | ||
* @returns A Promise for running the test. | ||
*/ | ||
export declare const runTestCase: (settings: ITestCaseSettings, autoMutatorFactory: AutoMutatorFactory) => Promise<void>; | ||
export declare const runTestCase: (settings: ITestCaseSettings, mutationsProviderFactory: IMutationsProviderFactory) => Promise<void>; |
@@ -39,2 +39,3 @@ "use strict"; | ||
exports.__esModule = true; | ||
var automutate_1 = require("automutate"); | ||
var chai_1 = require("chai"); | ||
@@ -46,7 +47,7 @@ var fs = require("mz/fs"); | ||
* @param settings Settings for the test case. | ||
* @param autoMutatorFactory Generates AutoMutator instances for testing. | ||
* @param autoMutatorFactory Creates mutation providers for files. | ||
* @returns A Promise for running the test. | ||
*/ | ||
exports.runTestCase = function (settings, autoMutatorFactory) { return __awaiter(_this, void 0, void 0, function () { | ||
var expectedContents, autoMutator, actualContents; | ||
exports.runTestCase = function (settings, mutationsProviderFactory) { return __awaiter(_this, void 0, void 0, function () { | ||
var expectedContents, logger, actualContents; | ||
return __generator(this, function (_a) { | ||
@@ -63,5 +64,9 @@ switch (_a.label) { | ||
expectedContents = (_a.sent()).toString(); | ||
autoMutator = autoMutatorFactory.create(settings.actual, settings.settings); | ||
logger = new automutate_1.Logger(); | ||
// Act | ||
return [4 /*yield*/, autoMutator.run()]; | ||
return [4 /*yield*/, automutate_1.runMutations({ | ||
logger: logger, | ||
mutationsApplier: new automutate_1.FileMutationsApplier({ logger: logger }), | ||
mutationsProvider: mutationsProviderFactory(settings.actual, settings.settings) | ||
})]; | ||
case 3: | ||
@@ -68,0 +73,0 @@ // Act |
@@ -1,2 +0,2 @@ | ||
import { IMutationsProviderFactory } from "./autoMutatorFactory"; | ||
import { IMutationsProviderFactory } from "./mutationsProviderFactory"; | ||
import { ITestCaseSettings } from "./testCase"; | ||
@@ -19,6 +19,2 @@ /** | ||
/** | ||
* Creates test cases from test case settings. | ||
*/ | ||
private readonly autoMutatorFactory; | ||
/** | ||
* Generates a directory-based test hierarchy from the file system. | ||
@@ -28,2 +24,6 @@ */ | ||
/** | ||
* Creates test cases from test case settings. | ||
*/ | ||
private readonly mutationsProviderFactory; | ||
/** | ||
* Settings for the test cases. | ||
@@ -30,0 +30,0 @@ */ |
@@ -41,3 +41,2 @@ "use strict"; | ||
var path = require("path"); | ||
var autoMutatorFactory_1 = require("./autoMutatorFactory"); | ||
var describeTests_1 = require("./describeTests"); | ||
@@ -59,3 +58,3 @@ var hierarchyCrawler_1 = require("./hierarchyCrawler"); | ||
function TestsFactory(mutationsProviderFactory, settings) { | ||
this.autoMutatorFactory = new autoMutatorFactory_1.AutoMutatorFactory(mutationsProviderFactory); | ||
this.mutationsProviderFactory = mutationsProviderFactory; | ||
this.settings = settings; | ||
@@ -94,3 +93,3 @@ this.hierarchyCrawler = new hierarchyCrawler_1.HierarchyCrawler(this.settings.original); | ||
} | ||
return [4 /*yield*/, testCase_1.runTestCase(caseSettings, this.autoMutatorFactory)]; | ||
return [4 /*yield*/, testCase_1.runTestCase(caseSettings, this.mutationsProviderFactory)]; | ||
case 1: | ||
@@ -114,4 +113,4 @@ _a.sent(); | ||
var createTestCaseSettings = function (settings, casePath) { | ||
var original = glob.sync(path.join(casePath, settings.original))[0]; | ||
if (original === undefined) { | ||
var matches = glob.sync(path.join(casePath, settings.original)); | ||
if (matches.length === 0) { | ||
return undefined; | ||
@@ -123,3 +122,3 @@ } | ||
expected: path.join(casePath, settings.expected), | ||
original: original, | ||
original: matches[0], | ||
settings: path.join(casePath, settings.settings) | ||
@@ -126,0 +125,0 @@ }; |
{ | ||
"name": "automutate-tests", | ||
"version": "0.2.3", | ||
"version": "0.3.0", | ||
"description": "Test harness for automutators.", | ||
@@ -30,13 +30,13 @@ "main": "lib/index.js", | ||
"devDependencies": { | ||
"@types/chai": "^4.1.2", | ||
"@types/chai": "^4.1.7", | ||
"@types/glob": "^7.1.1", | ||
"@types/mocha": "^5.0.0", | ||
"@types/mocha": "^5.2.5", | ||
"@types/mz": "0.0.32", | ||
"@types/node": "^9.6.0", | ||
"tslint": "^5.9.1", | ||
"typescript": "^2.7.2" | ||
"@types/node": "^10.12.18", | ||
"tslint": "^5.12.0", | ||
"typescript": "^3.2.2" | ||
}, | ||
"dependencies": { | ||
"automutate": "^0.5.3", | ||
"chai": "^4.1.2", | ||
"automutate": "^0.7.1", | ||
"chai": "^4.2.0", | ||
"chalk": "^2.4.1", | ||
@@ -43,0 +43,0 @@ "glob": "^7.1.3", |
@@ -1,4 +0,3 @@ | ||
export * from "./autoMutatorFactory"; | ||
export * from "./hierarchyCrawler"; | ||
export * from "./testCase"; | ||
export * from "./testsFactory"; |
@@ -1,6 +0,6 @@ | ||
import { AutoMutator } from "automutate"; | ||
import { FileMutationsApplier, Logger, runMutations } from "automutate"; | ||
import { expect } from "chai"; | ||
import * as fs from "mz/fs"; | ||
import { AutoMutatorFactory } from "./autoMutatorFactory"; | ||
import { IMutationsProviderFactory } from "./mutationsProviderFactory"; | ||
@@ -41,3 +41,3 @@ /** | ||
* @param settings Settings for the test case. | ||
* @param autoMutatorFactory Generates AutoMutator instances for testing. | ||
* @param autoMutatorFactory Creates mutation providers for files. | ||
* @returns A Promise for running the test. | ||
@@ -47,3 +47,3 @@ */ | ||
settings: ITestCaseSettings, | ||
autoMutatorFactory: AutoMutatorFactory, | ||
mutationsProviderFactory: IMutationsProviderFactory, | ||
): Promise<void> => { | ||
@@ -53,6 +53,10 @@ // Arrange | ||
const expectedContents: string = (await fs.readFile(settings.expected)).toString(); | ||
const autoMutator: AutoMutator = autoMutatorFactory.create(settings.actual, settings.settings); | ||
const logger = new Logger(); | ||
// Act | ||
await autoMutator.run(); | ||
await runMutations({ | ||
logger, | ||
mutationsApplier: new FileMutationsApplier({ logger }), | ||
mutationsProvider: mutationsProviderFactory(settings.actual, settings.settings), | ||
}); | ||
@@ -59,0 +63,0 @@ // Assert |
@@ -5,5 +5,5 @@ import chalk from "chalk"; | ||
import { AutoMutatorFactory, IMutationsProviderFactory } from "./autoMutatorFactory"; | ||
import { describeTests } from "./describeTests"; | ||
import { HierarchyCrawler, IHierarchy } from "./hierarchyCrawler"; | ||
import { IMutationsProviderFactory } from "./mutationsProviderFactory"; | ||
import { ITestCaseSettings, runTestCase } from "./testCase"; | ||
@@ -28,10 +28,10 @@ | ||
/** | ||
* Creates test cases from test case settings. | ||
* Generates a directory-based test hierarchy from the file system. | ||
*/ | ||
private readonly autoMutatorFactory: AutoMutatorFactory; | ||
private readonly hierarchyCrawler: HierarchyCrawler; | ||
/** | ||
* Generates a directory-based test hierarchy from the file system. | ||
* Creates test cases from test case settings. | ||
*/ | ||
private readonly hierarchyCrawler: HierarchyCrawler; | ||
private readonly mutationsProviderFactory: IMutationsProviderFactory; | ||
@@ -50,3 +50,3 @@ /** | ||
public constructor(mutationsProviderFactory: IMutationsProviderFactory, settings: ITestDescriptionSettings) { | ||
this.autoMutatorFactory = new AutoMutatorFactory(mutationsProviderFactory); | ||
this.mutationsProviderFactory = mutationsProviderFactory; | ||
this.settings = settings; | ||
@@ -89,3 +89,3 @@ | ||
await runTestCase(caseSettings, this.autoMutatorFactory); | ||
await runTestCase(caseSettings, this.mutationsProviderFactory); | ||
} | ||
@@ -92,0 +92,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
37
53385
1024
+ Addedautomutate@0.7.3(transitive)
- Removedautomutate@0.5.3(transitive)
Updatedautomutate@^0.7.1
Updatedchai@^4.2.0