2
votes

I'm trying to set up automated testing in TFS. I have a solution with one project in, and two unit tests.

I can build my solution in TFS fine, and have associated my test cases with the unit tests.

When I run a test case via TFS, the status changes to "In progress", and I can see my agent picking up the task. A few seconds later the agent prompts "Job Release completed with result: SucceededWithIssues". When I check the logs for the agent, the last line is complete.

When I go back to TFS, the status is still in "In progress".

When I click the Run icon, it prompts me with a dialogue immediately, with a button to "View test run". When I click there, it displays "Aborted just now, Ran for 03 seconds".

Test seklction

Can anyone help me in the right direction?

UPDATE

I managed to track down a log file :

2019-03-01T08:50:15.6478536Z Total Tests : 1, Passed Tests : 0
2019-03-01T08:50:18.6816644Z Test source filter: **\Tests.dll
2019-03-01T08:50:18.6816644Z Count of test sources found: 0
2019-03-01T08:50:18.6826624Z ##[warning]No test sources found
2019-03-01T08:50:18.6896764Z ##[error]ExecutionTaskStateModel.ExecuteTask: Recived error while executing task: System.AggregateException: One or more errors occurred. ---> System.InvalidOperationException: No test assemblies found on the test machine matching the source filter criteria or no tests discovered matching test filter criteria. Verify that test assemblies are present on the machine and test filter criteria is correct.

From my build log, I get this :

2019-03-01T10:34:58.4371090Z Total tests: 2. Passed: 2. Failed: 0. Skipped: 0.

So it picks up my tests in the right location, and passes them, in the build, but not in testing-post-build (post release?) stage.

So it's finding a test, but then prompting it's not finding a test? What am I missing?

UPDATE -

When trying to change test selection the test the assemblies, I am prompted with this error message. Test run

3
Did you double check the settings of your test task ? I mean, which assemblies you are testing, in which folder to search in, etc. Actually, maybe you could share with us those settings so we can help you better.Quentin S.
Thanks @QuentinS. I didnt want to share everything off the bat, to avoid information overload. What settings would you start off with?WynDiesel
Sure. I wanted to check your test selection settings, especially what you picked in the "Select tests using" field. Then, see what you entered in the fields below.Quentin S.
It says ##[warning]No test sources found. That means it can't discover the tests. Is your test assembly really named just "Tests.dll"? Do you have the appropriate test adapters for your test framework installed?Daniel Mann
@QuentinS., please see my edit to the question. I've added a screenshot. If there's anything else I can add, please let me know.WynDiesel

3 Answers

0
votes

You are testing your test assembly - here Tests.dll.

Try to select Test Assemblies in the test selection field.

Then, you can add your assembly directly in the Test assemblies list. Or you can use the following relative path (and excluding the obj folder):

**\Tests.dll 
!**\obj\**

enter image description here

Take a look here to understand the different test methods you can chose (test assembly/test plan/test run)

Also, be sure that Visual Studio is installed on your agent machine. Otherwise, look at this.

0
votes

The issue was inside the test cases. When I associated the unit test with a test case, the unit test was in the Test assembly, hence it trying to resolve the Test.dll.

In the test case, there's a tab to the right "Associated automation", in there :

enter image description here

0
votes

This answer is not intended to be a solution for the OP's question. However, it is possibly useful in general.

I do a lot of copy and pasting between test classes in VS. On my latest effort, I noticed this problem.

It turns out that I didn't add [TestClass] as an annotation for the class -- and unsurprisingly, this doesn't work.

So, if all else fails, check the annotations first!