I'm having trouble getting FitNesse to play nice with jmockit.
I'm using version v20110104 of FitNesse and version 0.999.9 of jmockit.
I had some ClassDefNotFound exceptions being thrown, but those were solved by adding the following to my FitNesse root:
!define COMMAND_PATTERN {java -javaagent:../lib/jmockit.jar}
Which is the location of my jmockit jar. However, now my tests that use jmockit hang in the "running" state, never to return.
I asked around on some FitNesse boards, and tried altering the command pattern like so:
!define COMMAND_PATTERN {java -javaagent:../lib/jmockit.jar -cp %p %m}
This defines the classpath (%p represents all defined path variables and %m represents the main java method)
This prevents the test from hanging, but I get a new exception:
java.lang.IllegalStateException: Invalid context for the recording of expectations
I can't find much information about this exception.
Has anyone gotten the latest release of jmockit to work with FitNesse?
This link may help you: http://tech.dir.groups.yahoo.com/group/fitnesse/message/17815
Are you using jmockit inside the fixtures, or how? What purpose? I'm just curious, had never needed to mock anything in my acceptance tests.
Related
I'm invoking the <java> task using Ant to run a program that prints out some stuff to stdout that ultimately, I'd like the user to be able to copy-paste easily. However, each line of stdout is prefixed with [java], which makes things needlessly challenging for the user.
Is there some way to print just the output of System.out.println(...) without getting prefixed with [java]?
Set ANT_ARGS=-emacs, see ant FAQ:
Ant adds a "banner" with the name of the current task in front of all
logging messages - and there are no built-in regular expressions in
your editor that would account for this.
You can disable this banner by invoking Ant with the -emacs switch.
[...]
Also ant manual Running Apache Ant listing all cli options might be helpful :
-emacs, -e produce logging information without adornments
I need to set classpath property in fitnesse slim. I have set as
!define CLASSPATH_PROPERTY {my-fitnesse-path}
!path ${CLASSPATH_PROPERTY}/fitnesse-20080812.jar
But it is not getting applied. Where and how should I set this CLASSPATH_PROPERTY?
Where to set 'CLASSPATH_PROPERTY?
!define CLASSPATH_PROPERTY {A_SELF_DEFINED_PROPERTY_NAME}
This is correct syntax to set it. You can set it anywhere before the test, either on the same page or on its parent page.
But I do have a feeling that you understand the usage of CLASSPATH_PROPERTY wrongly.
CLASSPATH_PROPERTY specifies the name of the environment variable into which the classpath (gathered from !path statements) will be placed before running the test. This is most commonly used when the size of the classpath is too large for certain inept operating systems to deal with. Instead of specifying the %p argument of the COMMAND_PATTERN, you can instead !define CLASSPATH_PROPERTY {CLASSPATH}. This is most useful for Java. For other languages it may not have much meaning.
Fitnesse use java -cp %p %m to launch a test. When CLASSPATH_PROPERTY is defined, whatever paths gathered from !path will be concated and placed into CLASSPATH_PROPERTY first and replace %p in the test launch command.
When this property is not defined, definitions from !path will be placed into %p directly. In fact, most of the time, this CLASSPATH_PROPERTY is not needed, unless you have a very very long classpath (or too many of them), as mentioned above.
I guess you just want to define classpath for your test. Just leave CLASSPATH_PROPERTY first, and put the full path into a !path statement first.
You should define the full class path using !path on your root page. so all the sub wiki's will use the same. Look at http://www.fitnesse.org/FitNesse.FullReferenceGuide.UserGuide.WritingAcceptanceTests.ClassPath for more info on it.
However if you want to mavenize your project, its a good idea to use maven-classpath-plugin and you define all your dependencies like in your case if you want to have specific fitnesse version under your classpath you define it as a dependency, that's all. On your root page this time instead of declaring 100 dependencies simply use !pomFile pom.xml and rest will be taken care by the plug-in. see https://github.com/amolenaar/fitnesse-maven-classpath for more info.
An example pom.xml might look something like below
<dependency>
<groupId>org.fitnesse</groupId>
<artifactId>fitnesse</artifactId>
<version>20150814</version>
</dependency>
.
.
<dependency>
<groupId>org.fitnesse.plugins</groupId>
<artifactId>maven-classpath-plugin</artifactId>
<version>1.6</version>
<!-- <scope>runtime</scope> -->
</dependency>
You can also use fitnesse launcher maven plug-in as well, which works great from my experience when you are working in a CI environment. Check http://fitnesse-launcher-maven-plugin.googlecode.com/svn/maven/site/fitnesse-launcher-maven-plugin/config.html for more info.
We have a setup like the following created with FitNesse for test automation:
MainPageSuite
SetupPage
ChildPage1Suite
SetupPage
Test
ChildPage2Suite
SetupPage
Test
We would like to use the SetupPage(s) to define the variables that need to be used. Currently when having the variables defined on the SetupPage(s) they are not functioning. When we just define them directly in the Test page they do work.
When the variabales are on the SetupPage we receive the following error:
fit:fit.FitServer Date: 9:06:22 AM (CEST) on donderdag, april 3, 2014
Test
Page: .MainPageSuite.ChildPage1Suite.Test
Command: java -cp fitnesse.jar;defaultPath fit.FitServer BDACCTEST
51439 3863 Exit code: 1 Time elapsed: 1.046 seconds
Standard Error: Error: Could not find or load main class fit.FitServer
The following variables were defined:
variable defined: TEST_SYSTEM=slim
variable defined: COMMAND_PATTERN=%m -r fitSharp.Slim.Service.Runner,c:\FitNesse\dotnet2\fitsharp.dll %p
variable defined: TEST_RUNNER=c:\FitNesse\dotnet2\Runner.exe
Does anyone have an idea what is wrong with our structure causing the SetupPage(s) not to work?
Add the variables to the root page of the Slim tests. This could be the root of the FitNesse wiki (e.g., localhost:8080/root) if we're only doing Slim tests, or on the Slim test page or suite page if we have a mix of Slim and Fit tests in the wiki.
You may have Java paths defined. Make sure the FitNesse root (e.g., localhost:8080/root) and any other pages don't contain Java paths. If you find the following, remove them.
!path classes
!path fitnesse.jar
!path fitlibrary.jar
From http://fitsharp.github.io/Slim/GettingStarted.html
If these variables are in the set up page, FitNesse is already processing the page as a Fit Java page before it reads them, instead of a Slim .NET page.
A 2.1.1 Grails app has a filter, and in development mode lines like this get printed on every request:
Filter says params are: [controller:book, action:list]
How can I stop this? (I don't think it is anything in my code doing it)
Are you using the functional test plugin? A quick Google search returned the suspect println you're seeing in the functional test plugin's grails-app/conf/TestFilters.groovy filter. If you are using the plugin, it looks like it's been removed/commited in Mar 2012, so you may need an update.
Otherwise if you're not using the functional test plugin, I would inspect your grails-app/conf/ directory for any *Filters.groovy and it's contents.
Im trying to write a logic that depends on the success or failure of cccheckout command. Is there something similar to returnProperty attribute as in exec task?
Thanks,
Aarthi
Looking at the CCCheckout documentation, I would rather use the exception mechanism to process any failure.
failonerr
Throw an exception if the command fails. Default is true.
Since ant 1.6.1
In ant, that means you can separate your ant process in two (one if no failure, one one exception), using the ant trycatch task.
It's possible you're asking that question because of cleartool.exe behaves strangly
sometimes, means it returns RC -1 even if no real error occured.
Means using cccheckout with failonerr="true" would sometimes cause an unneccessary Build failed
as any RC != 0 is handled as error by exec task.
But you might use the <exec> task directly with executable cleartool.exe and set attribute
resultproperty to make the RC available as property
outputproperty to make stdout available as property
errorproperty to make stderr available as property
for further processing, i.e. use condition task to check those properties..
Some try/catch/finally feature provided by Ant addons like :
AntContrib
Flaka
might come in handy, as VonC already mentioned.
If it gets more complicated afterwards use Groovy ant task or script task.