@cratis/pi 7.110.0 → 7.112.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package/corpus/harnesses/copilot/instructions/specs.csharp.instructions.md +1 -1
- package/package/corpus/hooks/scripts/cratis-check-pr.mjs +4 -2
- package/package/corpus/rules/specs.csharp.md +1 -1
- package/package/corpus/skills/cratis-specifications-csharp/references/shared-lifecycle.md +8 -4
- package/package/profile-catalog.json +5 -1
- package/package.json +1 -1
|
@@ -48,7 +48,7 @@ public class when_combining_parts : Specification
|
|
|
48
48
|
| `[Fact] void should_*()` | one assertion per fact | use the `ShouldXxx()` extension methods |
|
|
49
49
|
| `void Destroy()` | teardown after each fact by default | once per eligible class with shared lifecycle opt-in |
|
|
50
50
|
|
|
51
|
-
The shared lifecycle is the default on xUnit v2 and v3 since 5.0; the package registers the framework, so delete any hand-written `[assembly: Xunit.TestFramework(...)]` (it fails with `CS0579`). Eligible classes derive from `Specification`, have one public parameterless constructor
|
|
51
|
+
The shared lifecycle is the default on xUnit v2 and v3 since 5.0; the package registers the framework, so delete any hand-written `[assembly: Xunit.TestFramework(...)]` (it fails with `CS0579`). Eligible classes derive from `Specification`, have one public parameterless constructor and contain only plain facts. Construction, Establish/Because and Destroy run once; all facts share the instance and must not mutate it. `IDisposable` specifications also share the lifecycle since Cratis.Specifications 4.4.0: one construction and one `Dispose` after the last fact. Initialization failure fails every fact. Theories and `ITestOutputHelper` constructors keep per-fact execution; `[PerFactSpecificationLifecycle]` opts a class out. `CRSPEC0008` (a fact modifies the shared context) is an error by default: move the change into `Establish` or `Because`. See the **cratis-specifications-csharp** skill's shared-lifecycle reference.
|
|
52
52
|
|
|
53
53
|
Run specifications as the built executable, not `dotnet test`: restore and build once, then run `bin/<Config>/net10.0/<Project>.Specs`. In a solution that mixes Microsoft.Testing.Platform and VSTest projects, run each project on its own; `dotnet test` on the whole solution does not work there. Filters and the 4.x → 5.0 checklist are in the **cratis-specifications-csharp** skill's [running-specs reference](../../../skills/cratis-specifications-csharp/references/running-specs.md).
|
|
54
54
|
|
|
@@ -35,12 +35,14 @@ function readBodyFile(value) {
|
|
|
35
35
|
return readFileSync(resolved, 'utf8');
|
|
36
36
|
} catch (error) {
|
|
37
37
|
const parent = dirname(resolved);
|
|
38
|
+
const fileExists = existsSync(resolved);
|
|
38
39
|
const details = [`--body-file value: ${value}`, `path tried: ${resolved}`,
|
|
39
|
-
`parent directory exists: ${existsSync(parent)}`, `file exists now: ${
|
|
40
|
+
`parent directory exists: ${existsSync(parent)}`, `file exists now: ${fileExists}`,
|
|
40
41
|
`checker working directory: ${process.cwd()}`,
|
|
41
42
|
...Object.entries(invocation).map(([name, detail]) => `${name}: ${detail}`),
|
|
42
43
|
`checker script: ${fileURLToPath(import.meta.url)}`];
|
|
43
|
-
|
|
44
|
+
const hint = fileExists ? '' : ' If the file is written in the same batch of parallel tool calls as this command, write it in a separate, earlier step; the check runs before a concurrent write completes.';
|
|
45
|
+
throw new Error(`cannot read the pull-request body file (${error.code || error.message}); ${details.join('; ')}${hint}`, { cause: error });
|
|
44
46
|
}
|
|
45
47
|
}
|
|
46
48
|
const gh = (args, options = {}) => {
|
|
@@ -47,7 +47,7 @@ public class when_combining_parts : Specification
|
|
|
47
47
|
| `[Fact] void should_*()` | one assertion per fact | use the `ShouldXxx()` extension methods |
|
|
48
48
|
| `void Destroy()` | teardown after each fact by default | once per eligible class with shared lifecycle opt-in |
|
|
49
49
|
|
|
50
|
-
The shared lifecycle is the default on xUnit v2 and v3 since 5.0; the package registers the framework, so delete any hand-written `[assembly: Xunit.TestFramework(...)]` (it fails with `CS0579`). Eligible classes derive from `Specification`, have one public parameterless constructor
|
|
50
|
+
The shared lifecycle is the default on xUnit v2 and v3 since 5.0; the package registers the framework, so delete any hand-written `[assembly: Xunit.TestFramework(...)]` (it fails with `CS0579`). Eligible classes derive from `Specification`, have one public parameterless constructor and contain only plain facts. Construction, Establish/Because and Destroy run once; all facts share the instance and must not mutate it. `IDisposable` specifications also share the lifecycle since Cratis.Specifications 4.4.0: one construction and one `Dispose` after the last fact. Initialization failure fails every fact. Theories and `ITestOutputHelper` constructors keep per-fact execution; `[PerFactSpecificationLifecycle]` opts a class out. `CRSPEC0008` (a fact modifies the shared context) is an error by default: move the change into `Establish` or `Because`. See the **cratis-specifications-csharp** skill's shared-lifecycle reference.
|
|
51
51
|
|
|
52
52
|
Run specifications as the built executable, not `dotnet test`: restore and build once, then run `bin/<Config>/net10.0/<Project>.Specs`. In a solution that mixes Microsoft.Testing.Platform and VSTest projects, run each project on its own; `dotnet test` on the whole solution does not work there. Filters and the 4.x → 5.0 checklist are in the **cratis-specifications-csharp** skill's [running-specs reference](../skills/cratis-specifications-csharp/references/running-specs.md).
|
|
53
53
|
|
|
@@ -26,10 +26,14 @@ a duplicate fails the build with `CS0579`.
|
|
|
26
26
|
## Eligibility
|
|
27
27
|
|
|
28
28
|
A class is shared only when it derives from `Specification`, has a single public
|
|
29
|
-
parameterless constructor (or only framework-managed fixture arguments),
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
parameterless constructor (or only framework-managed fixture arguments), and has only
|
|
30
|
+
plain facts. Theories, `ITestOutputHelper` constructors, custom `IAsyncLifetime`
|
|
31
|
+
implementations, custom fact test cases and plain xUnit classes keep the per-fact lifecycle.
|
|
32
|
+
|
|
33
|
+
Requires Cratis.Specifications 4.4.0 or later for `IDisposable` specifications to share
|
|
34
|
+
the lifecycle; earlier versions use per-fact construction. With shared lifecycle enabled,
|
|
35
|
+
construction happens once and `Dispose` runs once after the last fact. Use
|
|
36
|
+
`[PerFactSpecificationLifecycle]` when a fresh instance per fact is needed.
|
|
33
37
|
|
|
34
38
|
`Specification.InitializeAsync()` is idempotent for a single instance. It does not make
|
|
35
39
|
an ineligible class shared or cache instances across classes.
|
|
@@ -927,7 +927,11 @@
|
|
|
927
927
|
"cratis-application-slice-specifications",
|
|
928
928
|
"cratis-chronicle-event-specifications",
|
|
929
929
|
"cratis-chronicle-read-model-specifications",
|
|
930
|
-
"cratis-specifications-csharp"
|
|
930
|
+
"cratis-specifications-csharp",
|
|
931
|
+
"coverage-analysis",
|
|
932
|
+
"filter-syntax",
|
|
933
|
+
"platform-detection",
|
|
934
|
+
"run-tests"
|
|
931
935
|
],
|
|
932
936
|
"languages": [
|
|
933
937
|
"csharp"
|