Skip to content

Commit

Permalink
fix(core): add test projects to solution
Browse files Browse the repository at this point in the history
Add generated test projects to the same solution as the main project
Co-authored-by: Ben Callaghan <bcallaghan@selectbankcard.com>
  • Loading branch information
Ben Callaghan authored and AgentEnder committed Dec 14, 2021
1 parent 56c770a commit 9090b99
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
12 changes: 12 additions & 0 deletions e2e/core-e2e/tests/nx-dotnet.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,5 +304,17 @@ describe('nx-dotnet e2e', () => {
expect(slnFile).toContain(app1);
expect(slnFile).toContain(app2);
});

it('should add test project to same solution as app project', async () => {
const app = uniq('app');
await runNxCommandAsync(
`generate @nx-dotnet/core:app ${app} --language="C#" --template="webapi" --test-template="xunit" --solutionFile`,
);

const slnFile = readFile('proj.nx-dotnet.sln');
expect(() => checkFilesExist(`apps/${app}`)).not.toThrow();
expect(slnFile).toContain(app);
expect(slnFile).toContain(app + '-test');
});
});
});
4 changes: 4 additions & 0 deletions packages/core/src/generators/utils/generate-test-project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
GetLintExecutorConfiguration,
GetTestExecutorConfig,
} from '../../models';
import { addToSolutionFile } from './add-to-sln';

import {
NormalizedSchema,
Expand Down Expand Up @@ -56,6 +57,9 @@ export async function GenerateTestProject(
}

dotnetClient.new(schema.testTemplate, newParams);
if (!isDryRun()) {
addToSolutionFile(host, testRoot, dotnetClient, schema.solutionFile);
}

if (!isDryRun() && !schema.skipOutputPathManipulation) {
await manipulateXmlProjectFile(host, {
Expand Down

0 comments on commit 9090b99

Please sign in to comment.