I have a number of unit tests organised hierarchically, all of which
inherit fixtures from a base class. To run these all at once I started
out using
from basic import map, directionalpan, layerorder, layervisibility ,
listlayers, streamlayerlist
# ... lots more ...
suite0 =
unittest.TestLo ader().loadTest sFromTestCase(d irectionalpan.T estPan)
suite1 =
unittest.TestLo ader().loadTest sFromTestCase(l ayerorder.TestL ayerorder)
# ... lots more ...
alltests = unittest.TestSu ite([suite0
, suite1
....])
unittest.TextTe stRunner(verbos ity=2).run(allt ests)
Which is unmaintainable. the TestLoader docs warn that
loadTestsFromMo dule will not play nicely with my situation and indeed
if I try
suite0 = unittest.TestLo ader().loadTest sFromModule(bas ic)
then run the tests, it hasn't picked any up. I suppose I could collect
and run the tests with a shell script...what are my options here to
avoid hardcoding and maintaining the list of tests, and how is it
normally done?
Thanks. 1 1494
OK, so I'm trying to collect the tests with python and add them to the
test suite dynamically, but I have a problem with module names. Here's
what I've got:
############### ##########
import os
from os.path import join
import unittest
alltests = unittest.TestSu ite()
def mightBeATest(f) :
#TODO check whether it really is a test
return f.endswith('.py ') and f != '__init__.py'
def isModule(d):
if not os.path.isdir(d ):
return False
for f in os.listdir(d):
if f == '__init__.py':
return True
return False
def getTestsFromDir (dir, currentmod):
for f in os.listdir(dir) :
if not f.startswith('. '):
if isModule(f):
#TODO how to check whether we are several modules in?
mod = __import__(f)
getTestsFromDir (os.path.join(d ir, f), mod)
elif mightBeATest(os .path.join(dir, f)):
fname, etx = os.path.splitex t(f)
print 'adding test
with',('alltest s.addTests(unit test.TestLoader ().loadTestsFro mTestCase('+(cu rrentmod.__dict __[fname])+'))')
eval('alltests. addTests(unitte st.TestLoader() .loadTestsFromT estCase('+curre ntmod.__dict__[fname]+'))')
getTestsFromDir (os.curdir, None)
print alltests.countT estCases()
############### #############
it's importing and referring to the current module that I have a
problem with...it gives me a key error. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Tom Verbeure |
last post by:
Hello All,
so I'm now convinced that unit testing is really the way to go and I
want to add it to an existing project. The first thing that I find
out, is that, well, it's hard work. Harder than writing the real
functional code.
My application manipulates graphs. I first write the skeleton in
Python, then convert it to C++ for high performance (some graphs can
have millions of nodes.)
|
by: |
last post by:
Hi!
I'm looking for unit-testing tools for .NET.
Somthing like Java has --> http://www.junit.org
regards,
gicio
|
by: Jacob |
last post by:
I have compiled a set og unit testing
recommendations based on my own experience
on the concept.
Feedback and suggestions for improvements
are appreciated:
http://geosoft.no/development/unittesting.html
Thanks.
|
by: Michael Bray |
last post by:
I've just inherited a fairly large project with multiple classes. The
developer also wrote a huge number of unit tests (using NUnit) to validate
that the classes work correctly. However, I don't think that the class
itself should include unit tests, especially since it has to reference
nunit.framework in order to compile/work, and I don't want to have to
distribute the nunit.framework.dll with this class.
So I created a new project,...
|
by: shuisheng |
last post by:
Dear All,
I was told that unit test is a powerful tool for progamming. If I am
writing a GUI code, is it possible to still using unit test?
I have a little experience in using unittest++. But I can not work out
a way to use it to test GUI code.
Thanks a lot!
| |
by: nw |
last post by:
Hi,
I previously asked for suggestions on teaching testing in C++. Based
on some of the replies I received I decided that best way to proceed
would be to teach the students how they might write their own unit
test framework, and then in a lab session see if I can get them to
write their own. To give them an example I've created the following
UTF class (with a simple test program following). I would welcome and
suggestions on how anybody...
|
by: Richard Lewis Haggard |
last post by:
We're using VS05 and today the units tests have stopped working in our
development environment. I'm sure that it is something really silly and
simple but I'll be darned if I can figure out what it is.
Here's a failure example: I created a simple little C# program called Test1.
I added a new class that has a public method Sum, which does the brilliant
function of adding two numbers together and returning the result.
I added a unit test...
|
by: Vyacheslav Maslov |
last post by:
Hi all!
I have many many many python unit test, which are used for testing some
remote web service.
The most important issue here is logging of test execution process and
result. I strongly need following:
1. start/end timestamp for each test case (most important)
2. immediate report about exceptions (stacktrace)
3. it will be nice to use logging module for output
|
by: =?Utf-8?B?cmFuZHkxMjAw?= |
last post by:
I'm working in Visual Studio 2005 Team Edition for Software Developers
I've used the wizard under the Test menu to create a bunch of unit tests.
When I click "Test -Start Selected Test Project with Debugger" the tests
run.
I'd really like to create a WinForm User Interface to run the Unit Tests.
The idea would be to give the user a list of Unit Tests in a table, and let
the user select any combination of tests they like. The user then...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |