Skip to content

Commit 9090b99

Browse files
Ben CallaghanAgentEnder
authored andcommitted
fix(core): add test projects to solution
Add generated test projects to the same solution as the main project Co-authored-by: Ben Callaghan <bcallaghan@selectbankcard.com>
1 parent 56c770a commit 9090b99

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

e2e/core-e2e/tests/nx-dotnet.spec.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,5 +304,17 @@ describe('nx-dotnet e2e', () => {
304304
expect(slnFile).toContain(app1);
305305
expect(slnFile).toContain(app2);
306306
});
307+
308+
it('should add test project to same solution as app project', async () => {
309+
const app = uniq('app');
310+
await runNxCommandAsync(
311+
`generate @nx-dotnet/core:app ${app} --language="C#" --template="webapi" --test-template="xunit" --solutionFile`,
312+
);
313+
314+
const slnFile = readFile('proj.nx-dotnet.sln');
315+
expect(() => checkFilesExist(`apps/${app}`)).not.toThrow();
316+
expect(slnFile).toContain(app);
317+
expect(slnFile).toContain(app + '-test');
318+
});
307319
});
308320
});

packages/core/src/generators/utils/generate-test-project.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
GetLintExecutorConfiguration,
99
GetTestExecutorConfig,
1010
} from '../../models';
11+
import { addToSolutionFile } from './add-to-sln';
1112

1213
import {
1314
NormalizedSchema,
@@ -56,6 +57,9 @@ export async function GenerateTestProject(
5657
}
5758

5859
dotnetClient.new(schema.testTemplate, newParams);
60+
if (!isDryRun()) {
61+
addToSolutionFile(host, testRoot, dotnetClient, schema.solutionFile);
62+
}
5963

6064
if (!isDryRun() && !schema.skipOutputPathManipulation) {
6165
await manipulateXmlProjectFile(host, {

0 commit comments

Comments
 (0)