Testing crons using collective.cron

Good day,
We are using collective.cron and it requires plone.app.async which runs only if a worker is active,
because I don't have a worker in the test environment the test will not run.

How do I activate plone.app.async or atleast access the worker in a test environment?
On the test layer I have tried adding self.loadZCML(package=collective.cron) and z2.installProduct(app, 'collective.cron')
but it makes no difference.

The error I get when I run the test and when the worker is not running is
"TypeError: 'NoneType' object is not iterable" which refers to self.queue

You should post the full buildout.cfg, your code, and the full error stack.

Thank you T. Kim for your reply and sorry for replying late here is my buildout

[buildout]
extends =
    base.cfg
    versions.cfg
#    http://dist.plone.org/release/4.3.10/versions.cfg
extensions +=
    mr.developer
sources = sources
auto-checkout = *
# If you change your Plone version, you'll also need to update
# the repository link below.
find-links +=
    http://dist.plone.org/release/4.3.10
# If you try to start Zope as root, it will change user id to run as
# the effective user specified here. This user id must own the var directory
# of your buildout.

# This user will own the rest of the installation, and should be used to
# run buildout.
# A flag to tell the Unified Installer whether or not to document sudo use.
need-sudo = no
eggs =
    Plone
    Pillow
    plone.reload
zcml =
    plone.reload
develop =
#    src/my.package
var-dir=${buildout:directory}/var
backups-dir=${buildout:var-dir}
deprecation-warnings = off
# change verbose-security to "on" for useful security errors while developing
verbose-security = off
parts =
    zeoserver
    client1
    client2
    worker
    repozo
    backup
    zopepy
    unifiedinstaller
    omelette
    i18ndude
    test
    robot
    coverage
    report
#[instance]
#<= instance_base
#recipe = plone.recipe.zope2instance
#http-address = 8090
[zeoserver]
<= zeoserver_base
recipe = plone.recipe.zeoserver
zeo-address = 127.0.0.1:8090
environment-vars =
    TZ Africa/Johannesburg
[client1]
<= client_base
recipe = plone.recipe.zope2instance
zeo-address = ${zeoserver:zeo-address}
http-address = 8091
zcml-additional =
    <include package="plone.app.async" file="single_db_instance.zcml" />
environment-vars =
    ZC_ASYNC_UUID ${buildout:directory}/var/client1-uuid.txt
    TZ Africa/Johannesburg
    PLONE_CSRF_DISABLED true
zope-conf-additional =
    <product-config zc.z3monitor>
        port 8358
    </product-config>
[client2]
<= client_base
recipe = plone.recipe.zope2instance
zeo-address = ${zeoserver:zeo-address}
http-address = 8092
zcml-additional =
    <include package="plone.app.async" file="single_db_instance.zcml" />
environment-vars =
    ZC_ASYNC_UUID ${buildout:directory}/var/client1-uuid.txt
    TZ Africa/Johannesburg
zope-conf-additional =
    <product-config zc.z3monitor>
        port 8358
    </product-config>
[worker]
<= client_base
recipe = plone.recipe.zope2instance
zeo-address = ${zeoserver:zeo-address}
http-address = 8089
zcml-additional =
    <include package="plone.app.async" file="single_db_worker.zcml" />
environment-vars =
    ZC_ASYNC_UUID ${buildout:directory}/var/worker-uuid.txt
    TZ Africa/Johannesburg
[sources]
[omelette]
recipe = collective.recipe.omelette
eggs =
    ${buildout:eggs}
[i18ndude]
unzip = true
recipe = zc.recipe.egg
eggs = i18ndude
#[zope2]
#recipe = plone.recipe.zope2install
[test]
recipe = zc.recipe.testrunner
defaults = ['--auto-color', '--auto-progress']
#defaults = ['--exit-with-status', '-v', '-s', 'plone.app.async']
#extra-paths = ${zope2:location}/lib/python
eggs =
    ${buildout:eggs}
    bika.lims [test]
    plone.app.async
    collective.cron [test]
[robot]
recipe = zc.recipe.egg
eggs =
    ${buildout:eggs}
    plone.app.robotframework
[coverage]
recipe = zc.recipe.egg
eggs = coverage
initialization =
    include = '--source=${buildout:directory}/src'
    sys.argv = sys.argv[:] + ['run', include, 'bin/test', '--all']
[report]
recipe = zc.recipe.egg
eggs = coverage
scripts = coverage=report
initialization =
    sys.argv = sys.argv[:] + ['html', '-i']
[versions]
zc.buildout = 2.5.2
setuptools = 23.1.0
Pillow = 3.2.0
MarkupSafe = 0.23
Products.DocFinderTab = 1.0.5
bobtemplates.plone = 1.0.3
buildout.sanitycheck = 1.0.2
collective.checkdocs = 0.2
collective.recipe.backup = 3.0.0
mr.bob = 0.1.2
pkginfo = 1.3.2
plone.recipe.unifiedinstaller = 4.3.2
requests = 2.10.0
requests-toolbelt = 0.6.2
twine = 1.7.2
zest.pocompile = 1.4
# Required by:
# clint==0.5.1
args = 0.1.0
# Required by:
# twine==1.7.2
clint = 0.5.1
# Required by:
# zest.releaser==6.6.2
colorama = 0.3.7

The code
Generic setup of crons
testing.py

Error I get when I run ./bin/test -m test_ARImport

Running bika.lims.testing.SimpleTestingLayer:Functional tests:
  Set up plone.testing.zca.LayerCleanup in 0.000 seconds.
  Set up plone.testing.z2.Startup in 0.270 seconds.
  Set up plone.app.testing.layers.PloneFixture in 9.524 seconds.
  Set up bika.lims.testing.SimpleTestLayer Traceback (most recent call last):
  File "/home/lunga/instances/emptybika/buildout-cache/eggs/zope.testing-3.9.7-py2.7.egg/zope/testing/testrunner/runner.py", line 366, in run_layer
    setup_layer(options, layer, setup_layers)
  File "/home/lunga/instances/emptybika/buildout-cache/eggs/zope.testing-3.9.7-py2.7.egg/zope/testing/testrunner/runner.py", line 628, in setup_layer
    setup_layer(options, base, setup_layers)
  File "/home/lunga/instances/emptybika/buildout-cache/eggs/zope.testing-3.9.7-py2.7.egg/zope/testing/testrunner/runner.py", line 633, in setup_layer
    layer.setUp()
  File "/home/lunga/instances/emptybika/buildout-cache/eggs/plone.app.testing-4.2.5-py2.7.egg/plone/app/testing/helpers.py", line 343, in setUp
    self.setUpPloneSite(portal)
  File "/home/lunga/instances/emptybika/zeocluster/src/bika.lims/bika/lims/testing.py", line 73, in setUpPloneSite
    applyProfile(portal, 'bika.lims:default')
  File "/home/lunga/instances/emptybika/buildout-cache/eggs/plone.app.testing-4.2.5-py2.7.egg/plone/app/testing/helpers.py", line 113, in applyProfile
    setupTool.runAllImportStepsFromProfile(profileId)
  File "/home/lunga/instances/emptybika/buildout-cache/eggs/Products.GenericSetup-1.8.3-py2.7.egg/Products/GenericSetup/tool.py", line 379, in runAllImportStepsFromProfile
    dependency_strategy=dependency_strategy)
   - __traceback_info__: profile-bika.lims:default
  File "/home/lunga/instances/emptybika/buildout-cache/eggs/Products.GenericSetup-1.8.3-py2.7.egg/Products/GenericSetup/tool.py", line 1414, in _runImportStepsFromContext
    message = self._doRunImportStep(step, context)
  File "/home/lunga/instances/emptybika/buildout-cache/eggs/Products.GenericSetup-1.8.3-py2.7.egg/Products/GenericSetup/tool.py", line 1226, in _doRunImportStep
    return handler(context)
   - __traceback_info__: collective.cron.setupCrons
  File "/home/lunga/instances/emptybika/buildout-cache/eggs/collective.cron-2.7-py2.7.egg/collective/cron/setuphandlers.py", line 63, in setupCrons
    exportimporter.do_import(xml)
  File "/home/lunga/instances/emptybika/buildout-cache/eggs/collective.cron-2.7-py2.7.egg/collective/cron/adapters/exportimport.py", line 81, in do_import
    crt.save()
  File "/home/lunga/instances/emptybika/buildout-cache/eggs/collective.cron-2.7-py2.7.egg/collective/cron/crontab.py", line 597, in save
    self.manager.save()
  File "/home/lunga/instances/emptybika/buildout-cache/eggs/collective.cron-2.7-py2.7.egg/collective/cron/adapters/registry.py", line 84, in save
    self.activated = self.context.activated
  File "/home/lunga/instances/emptybika/buildout-cache/eggs/collective.cron-2.7-py2.7.egg/collective/cron/adapters/registry.py", line 58, in _set_activated
    self.cronsettings.activated = value
  File "/home/lunga/instances/emptybika/buildout-cache/eggs/plone.registry-1.0.4-py2.7.egg/plone/registry/recordsproxy.py", line 47, in __setattr__
    self.__registry__[full_name] = value
  File "/home/lunga/instances/emptybika/buildout-cache/eggs/plone.registry-1.0.4-py2.7.egg/plone/registry/registry.py", line 47, in __setitem__
    self.records[name].value = value
  File "/home/lunga/instances/emptybika/buildout-cache/eggs/plone.registry-1.0.4-py2.7.egg/plone/registry/record.py", line 90, in _set_value
    notify(RecordModifiedEvent(self, oldValue, value))
  File "/home/lunga/instances/emptybika/buildout-cache/eggs/zope.event-3.5.2-py2.7.egg/zope/event/__init__.py", line 31, in notify
    subscriber(event)
  File "/home/lunga/instances/emptybika/buildout-cache/eggs/zope.component-3.9.5-py2.7.egg/zope/component/event.py", line 24, in dispatch
    zope.component.subscribers(event, None)
  File "/home/lunga/instances/emptybika/buildout-cache/eggs/zope.component-3.9.5-py2.7.egg/zope/component/_api.py", line 136, in subscribers
    return sitemanager.subscribers(objects, interface)
  File "/home/lunga/instances/emptybika/buildout-cache/eggs/zope.component-3.9.5-py2.7.egg/zope/component/registry.py", line 321, in subscribers
    return self.adapters.subscribers(objects, provided)
  File "/home/lunga/instances/emptybika/buildout-cache/eggs/zope.interface-3.6.7-py2.7-linux-x86_64.egg/zope/interface/adapter.py", line 585, in subscribers
    subscription(*objects)
  File "/home/lunga/instances/emptybika/buildout-cache/eggs/plone.registry-1.0.4-py2.7.egg/plone/registry/events.py", line 62, in redispatchInterfaceAwareRecordEvents
    adapters = subscribers((proxy, event), None)
  File "/home/lunga/instances/emptybika/buildout-cache/eggs/zope.component-3.9.5-py2.7.egg/zope/component/_api.py", line 136, in subscribers
    return sitemanager.subscribers(objects, interface)
  File "/home/lunga/instances/emptybika/buildout-cache/eggs/zope.component-3.9.5-py2.7.egg/zope/component/registry.py", line 321, in subscribers
    return self.adapters.subscribers(objects, provided)
  File "/home/lunga/instances/emptybika/buildout-cache/eggs/zope.interface-3.6.7-py2.7-linux-x86_64.egg/zope/interface/adapter.py", line 585, in subscribers
    subscription(*objects)
  File "/home/lunga/instances/emptybika/buildout-cache/eggs/collective.cron-2.7-py2.7.egg/collective/cron/adapters/registry.py", line 112, in synchronize_queue_edited
    plone, crt))
  File "/home/lunga/instances/emptybika/buildout-cache/eggs/zope.event-3.5.2-py2.7.egg/zope/event/__init__.py", line 31, in notify
    subscriber(event)
  File "/home/lunga/instances/emptybika/buildout-cache/eggs/zope.component-3.9.5-py2.7.egg/zope/component/event.py", line 24, in dispatch
    zope.component.subscribers(event, None)
  File "/home/lunga/instances/emptybika/buildout-cache/eggs/zope.component-3.9.5-py2.7.egg/zope/component/_api.py", line 136, in subscribers
    return sitemanager.subscribers(objects, interface)
  File "/home/lunga/instances/emptybika/buildout-cache/eggs/zope.component-3.9.5-py2.7.egg/zope/component/registry.py", line 321, in subscribers
    return self.adapters.subscribers(objects, provided)
  File "/home/lunga/instances/emptybika/buildout-cache/eggs/zope.interface-3.6.7-py2.7-linux-x86_64.egg/zope/interface/adapter.py", line 585, in subscribers
    subscription(*objects)
  File "/home/lunga/instances/emptybika/buildout-cache/eggs/collective.cron-2.7-py2.7.egg/collective/cron/adapters/manager.py", line 166, in do_synchronize
    ret = crona.synchronize_crontab_with_queue()
  File "/home/lunga/instances/emptybika/buildout-cache/eggs/collective.cron-2.7-py2.7.egg/collective/cron/adapters/manager.py", line 147, in synchronize_crontab_with_queue
    activated, _ = crona.register_or_remove()
  File "/home/lunga/instances/emptybika/buildout-cache/eggs/collective.cron-2.7-py2.7.egg/collective/cron/adapters/manager.py", line 95, in register_or_remove
    ret = self.register_job(force=force)
  File "/home/lunga/instances/emptybika/buildout-cache/eggs/collective.cron-2.7-py2.7.egg/collective/cron/adapters/manager.py", line 72, in register_job
    self.queue.cleanup_before_job(job_infos, force=force)
  File "/home/lunga/instances/emptybika/buildout-cache/eggs/collective.cron-2.7-py2.7.egg/collective/cron/adapters/ploneappasync.py", line 296, in cleanup_before_job
    j = self.get_job_in_queue(job_infos)
  File "/home/lunga/instances/emptybika/buildout-cache/eggs/collective.cron-2.7-py2.7.egg/collective/cron/adapters/ploneappasync.py", line 241, in get_job_in_queue
    for j in self.queue:
TypeError: 'NoneType' object is not iterable
Tearing down left over layers:
  Tear down plone.app.testing.layers.PloneFixture in 0.052 seconds.
  Tear down plone.testing.z2.Startup
Traceback (most recent call last):
  File "./bin/test", line 340, in <module>
    '--test-path', '/home/lunga/instances/emptybika/buildout-cache/eggs/collective.cron-2.7-py2.7.egg',
  File "/home/lunga/instances/emptybika/buildout-cache/eggs/zope.testing-3.9.7-py2.7.egg/zope/testing/testrunner/__init__.py", line 35, in run
    failed = run_internal(defaults, args, script_parts=script_parts)
  File "/home/lunga/instances/emptybika/buildout-cache/eggs/zope.testing-3.9.7-py2.7.egg/zope/testing/testrunner/__init__.py", line 48, in run_internal
    runner.run()
  File "/home/lunga/instances/emptybika/buildout-cache/eggs/zope.testing-3.9.7-py2.7.egg/zope/testing/testrunner/runner.py", line 138, in run
    self.run_tests()
  File "/home/lunga/instances/emptybika/buildout-cache/eggs/zope.testing-3.9.7-py2.7.egg/zope/testing/testrunner/runner.py", line 242, in run_tests
    tear_down_unneeded(self.options, (), setup_layers, True)
  File "/home/lunga/instances/emptybika/buildout-cache/eggs/zope.testing-3.9.7-py2.7.egg/zope/testing/testrunner/runner.py", line 605, in tear_down_unneeded
    l.tearDown()
  File "/home/lunga/instances/emptybika/buildout-cache/eggs/plone.testing-4.1.1-py2.7.egg/plone/testing/z2.py", line 354, in tearDown
    self.tearDownBasicProducts()
  File "/home/lunga/instances/emptybika/buildout-cache/eggs/plone.testing-4.1.1-py2.7.egg/plone/testing/z2.py", line 676, in tearDownBasicProducts
    with zopeApp() as app:
  File "/usr/lib/python2.7/contextlib.py", line 17, in __enter__
    return self.gen.next()
  File "/home/lunga/instances/emptybika/buildout-cache/eggs/plone.testing-4.1.1-py2.7.egg/plone/testing/z2.py", line 276, in zopeApp
    app = addRequestContainer(Zope2.app(connection), environ=environ)
  File "/home/lunga/instances/emptybika/buildout-cache/eggs/Zope2-2.13.24-py2.7.egg/Zope2/__init__.py", line 52, in app
    return bobo_application(*args, **kw)
  File "/home/lunga/instances/emptybika/buildout-cache/eggs/Zope2-2.13.24-py2.7.egg/App/ZApplication.py", line 75, in __call__
    return connection.root()[aname]
  File "/home/lunga/instances/emptybika/buildout-cache/eggs/ZODB3-3.10.5-py2.7-linux-x86_64.egg/ZODB/Connection.py", line 366, in root
    return RootConvenience(self.get(z64))
  File "/home/lunga/instances/emptybika/buildout-cache/eggs/ZODB3-3.10.5-py2.7-linux-x86_64.egg/ZODB/Connection.py", line 248, in get
    p, serial = self._storage.load(oid, '')
AttributeError: 'NoneType' object has no attribute 'load'

Seems bad that 'self' is undefined... I'd maybe try to narrow down what you include in your buildout.