5

I'm trying to run following simple test cases using pycharm, when I ran those test cases I see output

Process finished with exit code 0

instead pass/fail.

Test Case I was running :

import pytest from pytest1 import can_p1 msg=0 @pytest.fixture(scope = "module") def msgFraming(): print ("I'm inside FIXTURE") nchannel = 686 FuncID = 144 opType = 8 FuncID = FuncID * 2 msg = nchannel+FuncID+opType return msg def test_cansendMsg(msgFraming): res= can_p1.canMsgsend(msg) assert res == msg def test_canrecvMsg(msgFraming): res = can_p1.canMdgrcv(msg) assert res == msg 

I have edited settings in IDE as follows:

1) file -> settings -> tools -> python integrated tools -> set default as py.test

when I ran other programs(other than pytest) I can see o/p.

2
  • Pycharm should detect automatically if some functions begin with test..., what do you see when you right-click on the file tab ? "Run file" or "Run py.test in file" ? Commented Oct 2, 2017 at 17:09
  • I was seeing run file Commented Oct 3, 2017 at 17:15

3 Answers 3

4
  1. You need to edit/create new configuration by following this guide
  2. you need to choose python test and in the list choose pytest:

choose py.test

  1. edit the configurations by choosing the correct test file and the virtual environment : check enter image description here
  2. Apply/save and run the selected configuration , and it should works hope this will helps
Sign up to request clarification or add additional context in comments.

1 Comment

This says no tests were found
0

The setting you configured is correct. The next step would be to make a new run configuration for your tests. Right-click anywhere in your file and navigate the context menu. Look for an option labeled Create 'py.test in <file_name>.py'.... Select it, and a window should pop up showing the config PyCharm will create for your test file. Here you can add modifications to your config (the Target field should already be filled in with the correct info). When you are done, click Apply and then OK. Then you can run PyTest using this config by selecting it from the dropdown to the left of the green Run button. Once you have it selected, click the Run button and give it a go!

Comments

-1

maybe you have run the function before you use pytest, then the pycharm will auto create a configuration using python(not pytest), so delete the relative python configuration(or all python ) in run/debug configuration(do not forget to apply)

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.