You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltaspike.apache.org by gp...@apache.org on 2013/12/05 11:57:39 UTC

svn commit: r1548086 - /deltaspike/site/trunk/content/test-control.mdtext

Author: gpetracek
Date: Thu Dec  5 10:57:39 2013
New Revision: 1548086

URL: http://svn.apache.org/r1548086
Log:
test-control module documentation added

Added:
    deltaspike/site/trunk/content/test-control.mdtext

Added: deltaspike/site/trunk/content/test-control.mdtext
URL: http://svn.apache.org/viewvc/deltaspike/site/trunk/content/test-control.mdtext?rev=1548086&view=auto
==============================================================================
--- deltaspike/site/trunk/content/test-control.mdtext (added)
+++ deltaspike/site/trunk/content/test-control.mdtext Thu Dec  5 10:57:39 2013
@@ -0,0 +1,100 @@
+Title: Test-Control Module
+Notice:    Licensed to the Apache Software Foundation (ASF) under one
+           or more contributor license agreements.  See the NOTICE file
+           distributed with this work for additional information
+           regarding copyright ownership.  The ASF licenses this file
+           to you under the Apache License, Version 2.0 (the
+           "License"); you may not use this file except in compliance
+           with the License.  You may obtain a copy of the License at
+           .
+             http://www.apache.org/licenses/LICENSE-2.0
+           .
+           Unless required by applicable law or agreed to in writing,
+           software distributed under the License is distributed on an
+           "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+           KIND, either express or implied.  See the License for the
+           specific language governing permissions and limitations
+           under the License.
+
+[TOC]
+
+***
+
+# Intro
+
+This module is available since version 0.6 and allows to write CDI based tests easily.
+
+# CdiTestRunner
+
+JUnit Test-Runner to start/stop the CDI-Container autom. (per test-class) and one request and session per test-method:
+
+    :::java
+    @RunWith(CdiTestRunner.class)
+    public class ContainerAndInjectionControl
+    {
+        @Inject
+        private ApplicationScopedBean applicationScopedBean;
+ 
+        @Inject
+        private SessionScopedBean sessionScopedBean;
+ 
+        @Inject
+        private RequestScopedBean requestScopedBean;
+ 
+        //test the injected beans
+    }
+
+# @TestControl
+
+@TestControl allows to change the default-behavior. In the following case only one session for all test-methods (of the test-class) will be created:
+
+    :::java
+    @RunWith(CdiTestRunner.class)
+    @TestControl(startScopes = SessionScoped.class)
+    public class CustomizedScopeHandling
+    {
+        //inject beans and test them
+    }
+
+# CdiTestSuiteRunner
+
+JUnit Test-Suite-Runner to start/stop the CDI-Container autom. (per test-suite):
+
+    :::java
+    @RunWith(CdiTestSuiteRunner.class)
+    @Suite.SuiteClasses({
+        TestX.class,
+        TestY.class
+    })
+    public class SuiteLevelContainerControl
+    {
+    }
+
+# Project-Stage Control
+
+It's possible to overrule the default-project-stage for unit-tests (ProjectStage.UnitTest.class):
+
+    :::java
+    @RunWith(CdiTestRunner.class)
+    @TestControl(projectStage = CustomTestStage.class)
+    public class TestStageControl
+    {
+        //tests here will see project-stage CustomTestStage.class
+ 
+        @Test
+        @TestControl(projectStage = ProjectStage.Development.class)
+        public void checkDevEnv()
+        {
+        }
+ 
+        //tests here will see project-stage CustomTestStage.class
+    }
+
+# Hints
+
+Don't forget to add a beans.xml in the test-module (e.g. src/test/resources/META-INF/beans.xml).
+
+# SPI
+
+[TODO]
+