Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8277803
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T08:48:04+00:00 2026-06-08T08:48:04+00:00

I have some simple GWT client code that I would like to test using

  • 0

I have some simple GWT client code that I would like to test using GWTTestCase and GWTTestSuite.

However, those tests require the use of some CSS stylesheet (only needed for the tests).

My first attempt was :

  1. Define a ClientBundle that provide the CSS file used for tests.
  2. in my gwtSetUp(), call the `ensureInjected() method to add the CSS file before my tests get called
  3. Test if the CSS style was applied to a particular element in the DOM, for example

code:

assertEquals("blue", element.getStyle().getBorderColor());

I got no errors, but this not seems to work.

Looking throught the logs of the Console (during the Junit test) I found this :

Initializing ResourceGenerator
Finding operable CssResource subtypes
Computing CSS class replacements
Preparing method css
Finding resources
Parsing CSS stylesheet file:/D:/Workspace/libraries/gwt-text/gwt-text/src/test/java/com/t/i/client/CSSDecorationTest.css
Scanning CSS for requirements
Creating fields
Creating assignment for css()
Creating image sprite classes
Replacing property-based @if blocks
Replacing CSS class names
Performing substitution in node border-color : ….. ;

My css file simple contains :

.d {
    border-color: blue;
}

EDIT

Please see this link : https://stackoverflow.com/a/10575244/921244

This was the wrong approach as getStyle do not provide the CSS computed style. Too bad.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T08:48:06+00:00Added an answer on June 8, 2026 at 8:48 am

    If you don’t need to do anything special with your CSS (i.e. it’s a simple CSS, not a CssResource), then you could simply create a GWT module (gwt.xml file) dedicated for your tests (make it <inherits> your module-under-test and have your GWTTestCase‘s getModuleName return the name of the test-specific module instead of the module-under-test) in which you’d add a <stylesheet src="…" /> to include your stylesheet (simplest way if the stylesheet is only to be used for tests, put it in a public subfolder next to the test-specific gwt.xml file).
    See https://developers.google.com/web-toolkit/doc/latest/DevGuideOrganizingProjects#DevGuideAutomaticResourceInclusion

    Alternatively, using CssResource as you did, you might want to call StyleInjector.flush() just after your call to ensureInjected().

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some simple test code which I am trying to generate AVX optimized
I am using GWT (and GWT-Plateform) and GAE, and I would like to have
I have some simple code I am using to learn OAuth authentication using the
i have some simple code that does a preg match: $bad_words = array('dic', 'tit',
I have some simple constraints involving multiplication of reals in z3 that are producing
Let's say I have some simple Javascript like: <script> var hello = function(){ alert(Hello
I have some VERY simple code to return the title for a section header:
Have some simple jquery that Im trying to execute on a button click. For
I have developed a simple application in GWT. After that, I generate war file
I have a view that I created in my GWT application and I would

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.