From 51d16ddda4a39673290900625d911ce95dfd1569 Mon Sep 17 00:00:00 2001 From: Vladislav Panfilov Date: Thu, 29 Feb 2024 18:11:17 +0500 Subject: [PATCH 1/3] fix: regex for test declaration --- lua/neotest-phpunit/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/neotest-phpunit/init.lua b/lua/neotest-phpunit/init.lua index b6c1010..1e4ee25 100644 --- a/lua/neotest-phpunit/init.lua +++ b/lua/neotest-phpunit/init.lua @@ -102,7 +102,7 @@ function NeotestAdapter.discover_positions(path) )) @namespace.definition ((method_declaration - (name) @test.name (#match? @test.name "test") + (name) @test.name (#match? @test.name "^test") )) @test.definition (((comment) @test_comment (#match? @test_comment "\\@test") . From b10774a1ab49c60b15b455073c3d1f93f20d1d36 Mon Sep 17 00:00:00 2001 From: Vladislav Panfilov Date: Thu, 29 Feb 2024 18:12:35 +0500 Subject: [PATCH 2/3] feat: discovering tests marked with attribute --- lua/neotest-phpunit/init.lua | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lua/neotest-phpunit/init.lua b/lua/neotest-phpunit/init.lua index 1e4ee25..f5f0fdd 100644 --- a/lua/neotest-phpunit/init.lua +++ b/lua/neotest-phpunit/init.lua @@ -110,6 +110,16 @@ function NeotestAdapter.discover_positions(path) (name) @test.name ) @test.definition )) + + (((method_declaration + (attribute_list + (attribute_group + (attribute) @test_attribute (#match? @test_attribute "^Test$") + ) + ) + (name) @test.name + ) + )) @test.definition ]] return lib.treesitter.parse_positions(path, query, { From b06cceb19527dfb0ef3822ebab701d9f681bf256 Mon Sep 17 00:00:00 2001 From: Vladislav Panfilov Date: Fri, 1 Mar 2024 00:32:47 +0500 Subject: [PATCH 3/3] feat: add tests --- tests/Unit/ExampleTest.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/Unit/ExampleTest.php b/tests/Unit/ExampleTest.php index 7d58749..b1e1512 100644 --- a/tests/Unit/ExampleTest.php +++ b/tests/Unit/ExampleTest.php @@ -1,6 +1,7 @@ assertTrue(true); } + public function this_test_should_not_run_also() + { + $this->assertTrue(true); + } + + #[Test] + public function this_test_should_run() + { + $this->assertTrue(true); + } + /** * @dataProvider myProvider */