Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

testFailed message is not recognized as test failure when block is used #231

Open
cielavenir opened this issue Mar 27, 2020 · 13 comments
Open
Assignees

Comments

@cielavenir
Copy link

(Due to #230 , I had to decipher https://github.com/JetBrains/teamcity-messages/blob/master/tests/integration-tests/unittest_integration_test.py and got the raw command line python3 tests/guinea-pigs/unittest/subtest_named.py.)

From subtest_named I got the following teamcity message:

##teamcity[testCount timestamp='2020-03-27T14:45:59.159' count='1']
##teamcity[testStarted timestamp='2020-03-27T14:45:59.159' captureStandardOutput='true' flowId='__main__.NumbersTest.test_even (Test that numbers between 0 and 5 are all even_)' name='__main__.NumbersTest.test_even (Test that numbers between 0 and 5 are all even_)']
##teamcity[blockOpened timestamp='2020-03-27T14:45:59.159' flowId='__main__.NumbersTest.test_even (Test that numbers between 0 and 5 are all even_)' name='(i=0)' subTestResult='Success']
##teamcity[blockClosed timestamp='2020-03-27T14:45:59.159' flowId='__main__.NumbersTest.test_even (Test that numbers between 0 and 5 are all even_)' name='(i=0)']
##teamcity[blockOpened timestamp='2020-03-27T14:45:59.160' flowId='__main__.NumbersTest.test_even (Test that numbers between 0 and 5 are all even_)' name='(i=1)' subTestResult='Failure']
##teamcity[testStdErr timestamp='2020-03-27T14:45:59.160' flowId='__main__.NumbersTest.test_even (Test that numbers between 0 and 5 are all even_)' name='__main__.NumbersTest.test_even (Test that numbers between 0 and 5 are all even_)' out='SubTest failure: Traceback (most recent call last):|n  File "/home/mujin/mujin/jhbuildappteachworker/install/lib/python3.6/unittest/case.py", line 59, in testPartExecutor|n    yield|n  File "/home/mujin/mujin/jhbuildappteachworker/install/lib/python3.6/unittest/case.py", line 519, in subTest|n    yield|n  File "tests/guinea-pigs/unittest/subtest_named.py", line 16, in test_even|n    self.assertEqual(i % 2, 0)|n  File "/home/mujin/devel/teamcity-messages/teamcity/diff_tools.py", line 39, in _patched_equals|n    raise native_error|n  File "/home/mujin/devel/teamcity-messages/teamcity/diff_tools.py", line 32, in _patched_equals|n    old(self, first, second, msg)|n  File "/home/mujin/mujin/jhbuildappteachworker/install/lib/python3.6/unittest/case.py", line 821, in assertEqual|n    assertion_func(first, second, msg=msg)|n  File "/home/mujin/mujin/jhbuildappteachworker/install/lib/python3.6/unittest/case.py", line 814, in _baseAssertEqual|n    raise self.failureException(msg)|nAssertionError: 1 != 0|n|n']
##teamcity[blockClosed timestamp='2020-03-27T14:45:59.161' flowId='__main__.NumbersTest.test_even (Test that numbers between 0 and 5 are all even_)' name='(i=1)']
##teamcity[testFailed timestamp='2020-03-27T14:45:59.161' details='Failed subtests list: (i=1)' flowId='__main__.NumbersTest.test_even (Test that numbers between 0 and 5 are all even_)' message='One or more subtests failed' name='__main__.NumbersTest.test_even (Test that numbers between 0 and 5 are all even_)']
##teamcity[testFinished timestamp='2020-03-27T14:45:59.161' duration='1' flowId='__main__.NumbersTest.test_even (Test that numbers between 0 and 5 are all even_)' name='__main__.NumbersTest.test_even (Test that numbers between 0 and 5 are all even_)']

I made a teamcity job just to print this and running it caused the test passing. Teamcity summary definitely should show test failure.

test log in https://www.dropbox.com/sh/tvugn3zeebrhy8x/AABHy75s6Vu2Pflzl5HPslIya?dl=0

@cielavenir
Copy link
Author

Forgot to mention that I use TeamCity Enterprise 9.0.4 (build 32407)

@cielavenir
Copy link
Author

cielavenir commented Mar 30, 2020

Hi, I do have issues that I cannot utilize teamcity-messages for reporting tests if I print something in fixtures, which creates teamcity-message-block.

@cielavenir
Copy link
Author

How is this going? Pasting the teamcity message needs to report failure. Simple, isn't it?

If this is fixed in latest teamcity, could you provide an (command-line) option not to make block if test fixture has output?
Currently I need to sed pytest_plugin.py, which is pretty bad idea.

cielavenir added a commit to cielavenir/teamcity-messages that referenced this issue Apr 22, 2020
@cielavenir
Copy link
Author

cielavenir commented Apr 22, 2020

with #232 I don't have to sed-patch pytest_plugin.py at least.

@madlexa
Copy link
Contributor

madlexa commented Apr 28, 2020

Could you add a simple project with the problem?

@cielavenir
Copy link
Author

I did paste the log for the project.
As I'm not an admin of our teamcity server, I don't know how to post it here... Like this?

<?xml version="1.0" encoding="UTF-8"?>
<build-type xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" uuid="eef53c24-0255-4a9e-84bf-278be8b16c08" xsi:noNamespaceSchemaLocation="http://www.jetbrains.com/teamcity/schemas/9.0/project-config.xsd">
  <name>test-newline</name>
  <description />
  <settings>
    <parameters />
    <build-runners>
      <runner id="RUNNER_258" name="test" type="simpleRunner">
        <parameters>
          <param name="script.content"><![CDATA[cat subtest_named.log]]></param>
          <param name="teamcity.step.mode" value="default" />
          <param name="use.custom.script" value="true" />
        </parameters>
      </runner>
    </build-runners>
    <vcs-settings>
      <vcs-entry-ref root-id="aaa" />
    </vcs-settings>
    <requirements />
    <build-triggers />
    <cleanup />
  </settings>
</build-type>

@cielavenir
Copy link
Author

subtest_named.log exists above "I got the following teamcity message"

@madlexa
Copy link
Contributor

madlexa commented Apr 29, 2020

I'm sorry, I spelled it wrong. Could you give me 1 simple test to add to this library test base?

@cielavenir
Copy link
Author

Well, could you tell me how to interact teamcity server from teamcity-messages test suite?

The thing is I don't know whether teamcity-messages writes unexpected message or teamcity server interpretation is wrong. (I posted the issue to teamcity-messages in case of former).
I personally don't think that teamcity-message itself cannot judge the message itself's rightfulness (unless interacting with teamcity server).

@madlexa
Copy link
Contributor

madlexa commented Apr 29, 2020

TeamCity server parses output from a build and searches special messages #teamcity[...] for logic.
teamcity-messages only provides the output.

@cielavenir
Copy link
Author

cielavenir commented Apr 29, 2020

again, TC server does say success for the subtest_named test output even though it contains testFailed. Is this expected?

@madlexa
Copy link
Contributor

madlexa commented Apr 29, 2020

I will check it out.
Have you tested this on the new TeamCity version?
Could you give me a python test with this error?

@cielavenir
Copy link
Author

sorry, currently I can only access to TC 9.0.4.

The command is python3 tests/guinea-pigs/unittest/subtest_named.py, which is available at https://github.com/JetBrains/teamcity-messages/blob/master/tests/guinea-pigs/unittest/subtest_named.py .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants