8000 GitHub - syamantm/grinder-example: Load test example with The Grinder with java, dependency injection with PicoContainer
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

syamantm/grinder-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

grinder-example

Load test example with The Grinder with java, dependency injection with PicoContainer

References

The Grinder 3.11

PicoContainer

The Grinder with java

Overview

Key Concepts

  • Single script to bridge between java and jython
  • Pico container to inject dependencies to Test Runner.

Usage

  • Create a test runner by extending AbstractTestRunner.java:

      public class HttpGetTestRunner extends AbstractTestRunner {
      ....
      }
    
  • Inject test dependencies with @Resource annotation :

      public class HttpGetTestRunner extends AbstractTestRunner {
          ....
    
          @Resource
          private UrlProvider urlProvider;
    
          ....
      }
    
  • Based on the test need, a new implementation of the following providers/interfaces may be required:

    • UrlProvider - provides URL(s) to be tested.
    • DataProvider - provides json data to be tested(for put/post etc.).
    • HeaderProvider - provides http headers required for each http call( application/json, test/plain etc.).
  • Define the test runner and dependency classes in grinder properties(under src/test/grinder), e,g http-get.properties:

      ......
      java_test_runner = com.syamantakm.grinder.HttpGetTestRunner
      resource_classes=com.syamantakm.dao.SimpleJdbcDao;net.grinder.plugin.http.HTTPRequest;com.syamantakm.impl.HttpGetUrlProvider
      .....
    
  • grinder_pico.py will inject all the dependencies to the test runner class using PicoContainer, which is available with grinder.

      ....
      dependent_class_prop = grinder.getProperties().getProperty('resource_classes')
    
      print dependent_class_prop
    
      dependent_classes = []
      for dep_c in dependent_class_prop.split(';'):
          dep_class = load_class(dep_c)
          print dep_class
          dependent_classes.append(dep_class)
    
      class TestRunner:
    
          def __init__(self):
              pico = DefaultPicoContainer(AnnotatedFieldInjection(Resource));
    
              for dep_class in dependent_classes:
                  pico.addComponent(dep_class)
      ......
    

About

Load test example with The Grinder with java, dependency injection with PicoContainer

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0