Forum Discussion
Hm... I never have had the problem mentioned by AlexKaras.
I have set up the built in code editor of TestComplete in the same way as I have set up all of my other code editors and IDEs (like IDLE, Eclipse and Notepad++). Actually we only need to define the number of indents (spaces) per one block of code.
Also I am always using the source control system to store and update my code in a safe way. It's a kind of insurance for the case if I have broken something anyhow.
=====
MaheshBhoite, first of all you should define your framework architecture. In a very common approach you need to separate your test-steps from the test data, from application mapping and logic and from configuration and infrastructure. In other words your whole test should looks like:
myApp.start()
myApp.login()
myApp.doSomething()
myApp.validateSomething()
myApp.logout()
myApp.stop()
And nothing else.
Definition of all methods like start(), login() etc. should be hidden from your test in the separate module.
All infrastructure configuration like server name, data bases etc. should be hidden from your test in the separate module or inside of config- or ini- files.
All test data like credentials and other input values should be hidden from your test in the separate module, in variables or somewhere else.
All elements mapping should be hidden from your test in the separate module, classes or/and in the NameMapping repository.
...and so on
I haven't used the TC IDE with Python, but the indentation use is deliberate.
Python is designed to work this way.
https://www.python.org/dev/peps/pep-0008/
It is meant to encourage neat code design. And stop spaghetti code. Which I guess it does as spaghetti code in Python quickly becomes unreadable.
I guess if you REALLY wanted visual separators, you could always just use comments?
- AlexKaras8 years agoChampion Level 3
Hi Colin,
> Python is designed to work this way.
Yes, I know this.
This talk is, actually, out of scope, so quick comment without the intention for the discussion. :)
It is my personal opinion that not bad idea (code visual clarity) was implemented in an average way. The worst thing is that if for some reason (poor web page formatting, different editors, any other reason) original indentation of your code is broken, it is not easy task to restore it (which is equivalent to restore of the code logic). With the majority of other languages (Pascal, C, Java... Even VB) this is a matter of automated formatting.
In addition, personally I had a lot of inconveniences because of this Python feature. The case that I am used to use temporary debug logging. Especially in cases when debugger is not available. (E.g. TestExecute or Python without IDE set up.) To have those temporary debug logging statements to be easily identifiable later, I used to put them at the very beginning of the line. This is fast and makes those temporary lines of code visually quickly identifiable. Obviously, this approach does not work with Python and I had to indent those temporary statements and mark them with some comment to be able to identify them later. (BTW, I don't like automatic formatting in Visual Studio because of the same exact reason.)
Related Content
- 4 years agoAutomation1id
- 11 months agosanket2799
Recent Discussions
- 3 days agovladd1