Commit bedb28d
fix: TestExecutorAttribute respects scope hierarchy (method > class > assembly) (#4374)
* fix: TestExecutorAttribute respects scope hierarchy (method > class > assembly)
Add IScopedAttribute to TestExecutorAttribute, STAThreadExecutorAttribute, and
CultureAttribute to enable proper scope-based filtering. This ensures that
method-level executor attributes take precedence over class-level, which take
precedence over assembly-level.
Previously, all executor attributes from all scopes were invoked and each
would call SetTestExecutor(), with the last one winning (typically assembly-level
due to attribute collection order).
Now, the existing ScopedAttributeFilter mechanism properly filters executor
attributes to keep only the first occurrence (method-level due to method -> class
-> assembly collection order).
Fixes #4351
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* test: add tests for TestExecutorAttribute scope hierarchy
Add tests to verify that TestExecutorAttribute respects scope hierarchy:
- Method-level executor overrides class-level
- Class-level executor is used when no method-level exists
- Tests both generic and non-generic TestExecutor attributes
Verifies fix for #4351
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>1 parent 451aad2 commit bedb28d
File tree
9 files changed
+238
-24
lines changed- TUnit.Core/Attributes/Executors
- TUnit.PublicAPI
- TUnit.TestProject
- TestExecutors
9 files changed
+238
-24
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | | - | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
16 | 21 | | |
17 | 22 | | |
18 | 23 | | |
| |||
Lines changed: 7 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | | - | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
13 | 18 | | |
14 | 19 | | |
15 | 20 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | | - | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
12 | 17 | | |
13 | 18 | | |
14 | 19 | | |
15 | 20 | | |
16 | 21 | | |
17 | 22 | | |
18 | 23 | | |
19 | | - | |
| 24 | + | |
20 | 25 | | |
| 26 | + | |
21 | 27 | | |
22 | 28 | | |
23 | | - | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
24 | 34 | | |
25 | 35 | | |
26 | 36 | | |
| |||
Lines changed: 8 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1913 | 1913 | | |
1914 | 1914 | | |
1915 | 1915 | | |
1916 | | - | |
| 1916 | + | |
1917 | 1917 | | |
1918 | 1918 | | |
1919 | 1919 | | |
1920 | 1920 | | |
| 1921 | + | |
1921 | 1922 | | |
1922 | 1923 | | |
1923 | 1924 | | |
| |||
1938 | 1939 | | |
1939 | 1940 | | |
1940 | 1941 | | |
1941 | | - | |
| 1942 | + | |
1942 | 1943 | | |
1943 | 1944 | | |
1944 | 1945 | | |
| 1946 | + | |
1945 | 1947 | | |
1946 | 1948 | | |
1947 | 1949 | | |
1948 | | - | |
| 1950 | + | |
1949 | 1951 | | |
1950 | 1952 | | |
1951 | 1953 | | |
| 1954 | + | |
1952 | 1955 | | |
1953 | 1956 | | |
1954 | 1957 | | |
1955 | | - | |
| 1958 | + | |
1956 | 1959 | | |
1957 | 1960 | | |
1958 | 1961 | | |
1959 | 1962 | | |
| 1963 | + | |
1960 | 1964 | | |
1961 | 1965 | | |
1962 | 1966 | | |
| |||
Lines changed: 8 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1913 | 1913 | | |
1914 | 1914 | | |
1915 | 1915 | | |
1916 | | - | |
| 1916 | + | |
1917 | 1917 | | |
1918 | 1918 | | |
1919 | 1919 | | |
1920 | 1920 | | |
| 1921 | + | |
1921 | 1922 | | |
1922 | 1923 | | |
1923 | 1924 | | |
| |||
1938 | 1939 | | |
1939 | 1940 | | |
1940 | 1941 | | |
1941 | | - | |
| 1942 | + | |
1942 | 1943 | | |
1943 | 1944 | | |
1944 | 1945 | | |
| 1946 | + | |
1945 | 1947 | | |
1946 | 1948 | | |
1947 | 1949 | | |
1948 | | - | |
| 1950 | + | |
1949 | 1951 | | |
1950 | 1952 | | |
1951 | 1953 | | |
| 1954 | + | |
1952 | 1955 | | |
1953 | 1956 | | |
1954 | 1957 | | |
1955 | | - | |
| 1958 | + | |
1956 | 1959 | | |
1957 | 1960 | | |
1958 | 1961 | | |
1959 | 1962 | | |
| 1963 | + | |
1960 | 1964 | | |
1961 | 1965 | | |
1962 | 1966 | | |
| |||
Lines changed: 8 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1913 | 1913 | | |
1914 | 1914 | | |
1915 | 1915 | | |
1916 | | - | |
| 1916 | + | |
1917 | 1917 | | |
1918 | 1918 | | |
1919 | 1919 | | |
1920 | 1920 | | |
| 1921 | + | |
1921 | 1922 | | |
1922 | 1923 | | |
1923 | 1924 | | |
| |||
1938 | 1939 | | |
1939 | 1940 | | |
1940 | 1941 | | |
1941 | | - | |
| 1942 | + | |
1942 | 1943 | | |
1943 | 1944 | | |
1944 | 1945 | | |
| 1946 | + | |
1945 | 1947 | | |
1946 | 1948 | | |
1947 | 1949 | | |
1948 | | - | |
| 1950 | + | |
1949 | 1951 | | |
1950 | 1952 | | |
1951 | 1953 | | |
| 1954 | + | |
1952 | 1955 | | |
1953 | 1956 | | |
1954 | 1957 | | |
1955 | | - | |
| 1958 | + | |
1956 | 1959 | | |
1957 | 1960 | | |
1958 | 1961 | | |
1959 | 1962 | | |
| 1963 | + | |
1960 | 1964 | | |
1961 | 1965 | | |
1962 | 1966 | | |
| |||
Lines changed: 8 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1866 | 1866 | | |
1867 | 1867 | | |
1868 | 1868 | | |
1869 | | - | |
| 1869 | + | |
1870 | 1870 | | |
1871 | 1871 | | |
1872 | 1872 | | |
1873 | 1873 | | |
| 1874 | + | |
1874 | 1875 | | |
1875 | 1876 | | |
1876 | 1877 | | |
| |||
1890 | 1891 | | |
1891 | 1892 | | |
1892 | 1893 | | |
1893 | | - | |
| 1894 | + | |
1894 | 1895 | | |
1895 | 1896 | | |
1896 | 1897 | | |
| 1898 | + | |
1897 | 1899 | | |
1898 | 1900 | | |
1899 | 1901 | | |
1900 | | - | |
| 1902 | + | |
1901 | 1903 | | |
1902 | 1904 | | |
1903 | 1905 | | |
| 1906 | + | |
1904 | 1907 | | |
1905 | 1908 | | |
1906 | 1909 | | |
1907 | | - | |
| 1910 | + | |
1908 | 1911 | | |
1909 | 1912 | | |
1910 | 1913 | | |
1911 | 1914 | | |
| 1915 | + | |
1912 | 1916 | | |
1913 | 1917 | | |
1914 | 1918 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
0 commit comments